此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文档链接中了解了这一点。 verbose_eval =默认情况下为True,这将使其打印日志。
这些在训练后打印的日志是因为我们已经传递了Early_stopping_rounds的参数。