Sklearn GridSearchCV延迟

时间:2018-08-04 00:52:37

标签: python machine-learning scikit-learn grid-search hyperparameters

我正在使用此代码进行网格搜索

grid_search = GridSearchCV(gbm, param_grid, scoring='neg_mean_squared_error', n_jobs=-1, cv=predefined_split, verbose=2)
grid_result = grid_search.fit(df[features], df[target])

# summarize results
print("Best: %f using %s" % (grid_result.best_score_, grid_result.best_params_))
sys.stdout.flush()
means = grid_result.cv_results_['mean_test_score']
stds = grid_result.cv_results_['std_test_score']
params = grid_result.cv_results_['params']
for mean, stdev, param in zip(means, stds, params):
    print("%f (%f) with: %r" % (mean, stdev, param))

但是我看到的输出是

Start time GBM  2018-08-03 20:16:35.647916
{'n_estimators': [20, 40, 80]}
Fitting 1 folds for each of 3 candidates, totalling 3 fits
[CV] n_estimators=20 .................................................
[CV] n_estimators=40 .................................................
[CV] n_estimators=80 .................................................
[CV] .................................. n_estimators=20, total= 1.9min
[CV] .................................. n_estimators=40, total= 2.3min
[CV] .................................. n_estimators=80, total= 3.3min

[Parallel(n_jobs=-1)]: Done   3 out of   3 | elapsed:  3.5min finished

这样执行完成,但是在实际打印执行结果之前,我看到了很大的延迟。即输出冻结在那里,说“完成”,但是要花一段时间才能看到我想要的结果。为什么会这样,为什么我可以更快地看到输出,所以我不会浪费时间等待?

火车数据非常大,大约2GB。

那我怎样才能更快地刷新输出?

0 个答案:

没有答案