且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有自定义评估函数的 Python 中 xgboost 的意外行为

更新时间:2023-02-16 17:45:15

你得到 4 个评估矩阵,因为 xgboost 不知何故向你的 eval_set 添加了另一个评估指标.就个人而言,我使用的是核心 xgboost 而不是 scikit warp up.因此,如果您想了解更多信息,请在文档中阅读.

you get 4 evaluation matrices because somehow xgboost adding another evaluation metric to your eval_set. personally, I'm using the core xgboost and not the scikit warp up. So if you want to learn more, read about it in the documentation.

对于early_stopping,您必须将n_estimators=1000(或您想要的迭代次数)设置为xgb.XGBClassifier 中的参数

for early_stopping, you have to set n_estimators=1000 (or how many iterations you want) as a parameter in xgb.XGBClassifier

并在 clf.fit 中设置 early_stopping_rounds=50(或您想要的任何值).这是文档.

And set early_stopping_rounds=50 (or what ever value you want) in clf.fit. Here's the documentation.

提前停止决定何时需要停止提升算法以避免过度拟合.它是通过评估您在 eval_set 中定义的 tuple (X_test, y_test) 来实现的.如果评估误差在 50 次迭代中没有减少,则 early_stopping 将停止您的提升.

early stopping comes to decide when you need to stop boosting the algorithm to avoid over fitting. it is doing so by evaluating your tuple (X_test, y_test) you defined in eval_set. early_stopping will stop your boosting if the evaluation error hasn't decrease over 50 iterations.