【问题标题】:Xgboost. obtain the booster from the best iterationXgboost。从最佳迭代中获得助推器
【发布时间】:2018-09-09 07:58:24
【问题描述】:

我正在使用 Xgboost.train 来训练我的模型;但是,我不确定如何从最佳迭代中获得助推器,而不是从最后一次迭代中获得助推器。

    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

【问题讨论】:

    标签: python machine-learning xgboost


    【解决方案1】:

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

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

    或使用Param @ 987654323,保证您将在最佳树附近得到树。但要小心这个参数,原因评估值可以处于局部最小或最大值(取决于评估函数)。

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

    【讨论】:

      猜你喜欢
      • 2019-01-28
      • 2017-03-22
      • 2021-01-17
      • 2021-02-20
      • 2021-05-06
      • 2020-01-01
      • 1970-01-01
      • 2019-07-22
      • 1970-01-01
      相关资源
      最近更新 更多