【问题标题】:setting booster in a XGBClassifier在 XGBClassifier 中设置助推器
【发布时间】:2026-01-02 08:50:01
【问题描述】:

我阅读了文档,

import xgboost as xgb
class xgboost.XGBClassifier(max_depth=3, learning_rate=0.1,
n_estimators=100, silent=True, objective='binary:logistic',
booster='gbtree', n_jobs=1,nthread=None, gamma=0, min_child_weight=1,
max_delta_step=0, subsample=1, colsample_bytree=1, colsample_bylevel=1, 
reg_alpha=0, reg_lambda=1, scale_pos_weight=1, base_score=0.5, 
random_state=0, seed=None, missing=None, **kwargs)

然后我尝试按照 API 创建自己的实例

model_benchmark=xgb.XGBClassifier(booster ='linear',objective='binary:logistic')

我得到:

TypeError: __init__() got an unexpected keyword argument 'booster'

关于如何选择我想要的助推器有什么建议吗?

【问题讨论】:

    标签: python machine-learning scikit-learn xgboost


    【解决方案1】:

    https://anaconda.org/conda-forge/py-xgboost

    以上可用于在Anaconda上安装0.80版本的xgboost,带有booster参数。

    【讨论】:

      【解决方案2】:

      更新:

      我查看了 v0.6 的 Github 源代码,没有找到任何与 booster 参数相关的内容。该参数在最新版本的发布中。但是,在 0.6 版本中也有一些关于 Booster 对象的信息,但它的使用可能比最新版本的实现方式更复杂。


      根据文档 (http://xgboost.readthedocs.io/en/latest/python/python_api.html):

      booster: string
      Specify which booster to use: gbtree, gblinear or dart.
      

      没有“线性”,应该是“gblinear”。

      【讨论】:

      • 谢谢。但当然不能解决。见回溯。整个助推器 arg 出现意外
      • @ErroriSalvo 您使用的是什么 xgboost 版本?也可能是版本问题,尝试更新到最新版本再试一次。
      • 0.6。我绝对不能更新。我希望只是名称已更改,因为这是 xgboost 的关键属性... :(
      • @ErroriSalvo 我查看了 v0.6 的 github 源代码,并没有找到与 booster 参数相关的任何内容。该参数在最新版本的发布中。然而,在 0.6 版本中也有一些关于 Booster 对象的信息,但它的使用可能比最新版本的实现方式更复杂。
      • 谢谢,太好了。也许您可以将此评论作为答案?