首页 > 解决方案 > 参数:{ scale_pos_weight } 可能不会被使用

问题描述

我正在处理这个警告:

[20:16:09] WARNING: ../src/learner.cc:541: 
Parameters: { scale_pos_weight } might not be used.

  This may not be accurate due to some parameters are only used in language bindings but
  passed down to XGBoost core.  Or some parameters are not used but slip through this
  verification. Please open an issue if you find above cases.

在 Python 中训练 XGBoost 时。

我一直在研究它,这是由于分类类型(二进制或多类)。问题是我正在对不平衡数据(6483252 负 / 70659 正)进行二进制分类,所以我需要设置该参数以便在训练期间考虑这种不平衡,但我不明白为什么我会收到那个警告:(

这就是我初始化和训练 XGBoost 的方式:

param = {'n_jobs':-1, 'random_state':5, 'booster':'gbtree', 'seed':5, 'objective': 'binary:hinge',  'scale_pos_weight':ratio}
param['eval_metric'] = ['auc', 'aucpr', 'rmse', 'error']

xgb_clf =xgb.XGBClassifier(**param)
xgb_clf.fit(dtrain,y_train)

dtrain 是熊猫数据框,y_train 是带有标签 (0,1) 的熊猫系列。

谢谢!

标签: pythonxgboostxgbclassifier

解决方案


可能的修复是2:

  • 您的训练集是多类的,然后参数无效。
  • 实现中的 n_jobs 问题(将 n_jobs 设置为 0)

这是最常见的问题


推荐阅读