【问题标题】:XGBoost error - Unknown objective function reg:squarederrorXGBoost 错误 - 未知目标函数 reg:squarederror
【发布时间】:2019-10-07 10:51:16
【问题描述】:

我正在为回归任务训练一个 xgboost 模型,并且我传递了以下参数 -

params = {'eta':0.4, 'max_depth':5, 'colsample_bytree':0.6, 'objective':'reg:squarederror'}
num_round = 10
xgb_model = xgboost.train(params, dtrain_x, num_round)

在训练阶段我收到以下错误-

XGBoostError: b'[18:03:23] C:\Users\xgboost\src\objective\objective.cc:23: 未知目标函数 reg:squarederror'

docs 中,它显然是一个有效的目标函数。谁能告诉我为什么会出现这个错误?

INFO- 我在 windows 上使用 python 3.7.3,xgboost 版本是 0.82

【问题讨论】:

  • 您是否尝试升级 xgboost (pip install --upgrade xgboost) 和 scipy (pip install --upgrade scipy)?今天它对我有用。我有同样的问题
  • @LumberJack 我刚刚将 xgboost 升级到 0.90 版,它工作正常。谢谢。

标签: python-3.x regression xgboost


【解决方案1】:
xgb_model = xgboost.train(**params, dtrain_x, num_round)

这适用于所有版本。这是将**kwargs 作为字典传递的方式。

What does ** (double star/asterisk) and * (star/asterisk) do for parameters?

【讨论】:

  • 这在任何版本中都不起作用,因为 python 不允许在位置参数之前使用关键字参数。
猜你喜欢
  • 2023-03-15
  • 2021-11-02
  • 2023-02-08
  • 1970-01-01
  • 2021-03-23
  • 1970-01-01
  • 2018-11-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多