XGBoost的评估AUC值一直在下降,而训练AUC值却在上升,这种结果正常吗?

我想使用XGBoost的early_stopping_rounds参数来进行不过拟合的训练。为此,我使用了以下代码:

parameters = {'nthread': 4,'objective': 'binary:logistic','learning_rate': 0.06,'max_depth': 6,'min_child_weight': 3,        'silent': 0,'gamma': 0,'subsample': 0.7,'colsample_bytree': 0.5,'n_estimators': 5,        'missing': -999,'scale_pos_weight': scale_pos_weight,'seed': 4789,'eval_metric':'auc','early_stopping_rounds': 100}X_train, X_test, y_train, y_test =train_test_split(train_feature,train_label, test_size=0.3, random_state=4789)dtrain = xgb.DMatrix(X_train, label=y_train)dtest = xgb.DMatrix(X_test, label=y_test)evallist = [(dtest, 'eval'), (dtrain, 'train')]bst = xgb.train(parameters, dtrain,num_boost_round=1500, evals=evallist)

当打印中间结果时,我得到了如下日志:

[1469]  eval-auc:0.912417   train-auc:0.986104[16:04:23] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 110 extra nodes, 0 pruned nodes, max_depth=6[1470]  eval-auc:0.912412   train-auc:0.986118[16:04:27] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 102 extra nodes, 0 pruned nodes, max_depth=6[1471]  eval-auc:0.912405   train-auc:0.986129[16:04:30] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 116 extra nodes, 0 pruned nodes, max_depth=6[1472]  eval-auc:0.912383   train-auc:0.986143[16:04:34] src/tree/updater_prune.cc:74: tree pruning end, 1 roots, 116 extra nodes, 0 pruned nodes, max_depth=6[1473]  eval-auc:0.912375   train-auc:0.986159

现在我想知道这种训练结果是否正确?如何检测我的模型是否过拟合,以及应该选择多少轮次?


回答:

正如@XXX所说,你看到的结果是正确的——你的模型刚开始过拟合。

关于你的第二个问题,early_stopping_rounds参数的工作方式是在N轮之后如果评估AUC没有改善就停止训练(N是early_stopping_rounds的值)。请注意,中间评估AUC值可能会下降,但只要在最后N轮中有任何绝对改善,训练就会继续进行。

在你的例子中,第1469轮的评估AUC值达到了最大值,因此训练不会在第1569轮之前停止(按照设定,100轮之后)。

最后,达到的最佳轮次应该存储在你示例中的bst变量中。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注