如何从 xgboost 中检索正则化项

How to retrieve regularisation term from xgboost

为了评估偏差方差权衡,我更喜欢绘制预测误差与受训估计器复杂性的关系图。 error vs complexity plot

如果是 xgboost the documentation states that the complexity is taken as the regularisation term of the objective function。所以按原理来说应该很容易生成这样的图。

但是,我不知道如何检索训练模型的计算正则化项。我正在使用 Python scikit-learn API.

这个值在库中是否可用,还是应该在训练后重新计算?

不需要检索,需要设置正则化。正则化越低,模型越复杂,反之亦然。在 XGBoost 的情况下,正则化是 lambda (a link for the documentation).

您需要遍历 l2 值列表,训练模型并计算训练和测试子集的误差。

这里还有good article如何调整 XGBoost 的正则化。