XGBoost 运行 在终端和笔记本上两次

XGBoost running twice on terminal and notebook

此代码用于 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_))

首先会在终端输出

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

谁能解释一下这个现象?

我从 this 文档 link 中了解到这一点。 verbose_eval = 默认情况下为 True,这会导致它打印日志。

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