【问题标题】:XGBoost running twice on terminal and notebookXGBoost 在终端和笔记本上运行两次
【发布时间】:2020-01-11 09:25:22
【问题描述】:

此 XGBoost 代码运行两次

#https://towardsdatascience.com/running-xgboost-on-google-colab-free-gpu-a-case-study-841c90fef101

num_folds = 3
cv = StratifiedKFold(n_splits=num_folds, random_state =seed)
param_grid = {
        'classifier__max_depth': [3],
        'classifier__n_estimators': [200]
    }

gs3 = GridSearchCV(pipeline, param_grid, cv = cv, scoring = 'roc_auc', n_jobs = -1,\
                  verbose = False, return_train_score = True, refit = True)

fit_params={"classifier__early_stopping_rounds": 20, 
            "classifier__eval_metric" : ["error","auc"],
#             "classifier__verbose_eval" : 10,
            "classifier__eval_set" : [[X_train, y_train],[X_test, y_test]]}
            
%time gs3 = gs3.fit(X_train, y_train, **fit_params)
print(("best score from grid search: %.3f"
       % gs3.best_score_))

首先它会在终端上输出

然后它会在笔记本上再次运行

谁能解释一下这个现象?

【问题讨论】:

    标签: python machine-learning jupyter-notebook data-science xgboost


    【解决方案1】:

    我从this 文档链接中发现了这一点。 verbose_eval = True 默认情况下会导致它打印日志。

    训练后打印的这些日志是因为我们已经为 early_stopping_rounds 传递了参数。

    【讨论】:

      猜你喜欢
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-12
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 2018-09-23
      相关资源
      最近更新 更多