python - 为什么XGBoost安装中没有booster参数,而文档中却有?

标签 python machine-learning xgboost

我已经安装了 XGBoost。 这些是执行以下操作时显示的参数: 打印(xgboost.XGBClassifier())

XGBClassifier(base_score=0.5, colsample_bylevel=1, colsample_bytree=1,
   gamma=0, learning_rate=0.1, max_delta_step=0, max_depth=3,
   min_child_weight=1, missing=None, n_estimators=100, nthread=-1,
   objective='binary:logistic', reg_alpha=0, reg_lambda=1,
   scale_pos_weight=1, seed=0, silent=True, subsample=1)

但在文档中Scikit-Learn API ,出现“booster”参数”,为什么我没有?

Scikit-Learn API
Scikit-Learn Wrapper interface for XGBoost.

class xgboost.XGBRegressor(max_depth=3, learning_rate=0.1,  
n_estimators=100, silent=True, objective='reg:linear', 
**booster='gbtree'**, nthread=-1, 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, seed=0, 
missing=None)

编辑

这就是我得到的:

    ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-63-26499cfcb8f8> in <module>()
     18         #Inicio de Cross-validation
     19         clf = Pipeline([('rcl', RobustScaler()),
---> 20                         ('clf',    xgboost.XGBClassifier(booster='gbtree', objective='multi:softmax', seed=0,  nthread=-1))])
     21         ##############4 epoch x sujeto###########
     22         print("4 epoch x sujeto en test_size")

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

最佳答案

恕我直言,这是一个严重的不一致,您应该为此提出一个问题。

但是 XGB python 类或多或少是围绕这样一个事实而设计的:您可以通过 train 方法在包中设置参数。

因此,您实际上可以通过以下方式提供 booster 方法:

clf = xgb.XGBClassifier()
params = {"booster" : "gbtree"}
xgb.train(params, ...)

关于python - 为什么XGBoost安装中没有booster参数,而文档中却有?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44074078/

相关文章:

r - 如何限制执行时间但将输出保存在R中?

python - Scipy:通过 cdist 计算标准化欧几里德

python - GQL 获取 ID 字段

python - sklearn "RidgeClassifier"是做什么的?

python-3.x - 具有自定义评估函数的 Python 中 xgboost 的意外行为

Python - 我获得了包含 XGBoost 模型的 pickle 文件。如何找到文件的详细信息?

python - 我如何在ubuntu上的python3.7中安装opencv?

python - 在python中绘制多条线

r - r 中的最佳簇数

machine-learning - 机器学习中的逻辑回归