XG增压。从最佳迭代中获得助推器

2024-06-16 08:32:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用XG增压列车为了训练我的模型;然而,我不确定如何从最佳迭代中获得助推器,而不是从上一次迭代中获得助推器。在

    xgb1=xgb.train(self.params,xgtrain,num_boost_round=self.num_boost_round,early_stopping_rounds=self.early_stopping_rounds,evals=watchlist)
    print xgb1.best_score
    print xgb1.best_iteration
    print xgb1.best_ntree_limit

Tags: 模型selfnumbestprintboostround列车
1条回答
网友
1楼 · 发布于 2024-06-16 08:32:17

在模型中进行预测时,可以将此设置为:

preds = xgb1.predict(testset, ntree_limit=xgb1.best_iteration)

或者使用参数early_stopping_rounds,它可以保证您可以在最佳树附近找到树。但是要小心这个参数,因为求值值可以是局部最小值或最大值(取决于求值函数)。在

你也可以在这里看到:https://github.com/dmlc/xgboost/issues/264

相关问题 更多 >