5

Is it possible to see the progress of GridSearchCV in a Jupyter Notebook? I'm running this script in python:

param_grid = {'learning_rate': [0.05, 0.10, 0.15, 0.20, 0.25, 0.30] ,
'max_depth'        : [3, 4, 5, 6, 8, 10, 12, 15],
'min_child_weight' : [1, 3, 5, 7],
'gamma'            : [0.0, 0.1, 0.2 , 0.3, 0.4],
'colsample_bytree' : [0.3, 0.4, 0.5 , 0.7],
'verbose'          : [100] }

xgboost_reg = XGBRegressor()
grid_search = GridSearchCV(xgboost_reg, param_grid, cv=5, scoring='neg_mean_squared_error', return_train_score=True)
grid_search.fit(my_data, my_labels, verbose=False)

I can see only some warnings in the output of the cell.

Ralf Hundewadt
  • 1,078
  • 1
  • 13
  • 25
  • Check this Question it could be helpful : https://stackoverflow.com/questions/24121018/sklearn-gridsearch-how-to-print-out-progress-during-the-execution – Kaies LAMIRI Jun 07 '19 at 14:25

2 Answers2

6

You want the verbose parameter:

grid_search = GridSearchCV(xgboost_reg, param_grid, cv=5, scoring='neg_mean_squared_error', return_train_score=True, verbose=2)
grid_search.fit(my_data, my_labels, verbose=False)

An example of what I got on toy data:

Fitting 3 folds for each of 5 candidates, totalling 15 fits
[CV] C=0.1 ...........................................................
[CV] ............................................ C=0.1, total=   0.0s
[CV] C=0.1 ...........................................................
[CV] ............................................ C=0.1, total=   0.0s
[CV] C=0.1 ...........................................................
[CV] ............................................ C=0.1, total=   0.0s
[CV] C=0.5 ...........................................................
[CV] ............................................ C=0.5, total=   0.0s
[CV] C=0.5 ...........................................................
[CV] ............................................ C=0.5, total=   0.0s
[CV] C=0.5 ...........................................................
[CV] ............................................ C=0.5, total=   0.0s
gmds
  • 19,325
  • 4
  • 32
  • 58
1

In my case I had to set n_jobs to 1 which indicates that sklearn cannot handle output of multiple processes correctly.

If n_jobs is not 1 no output is provided.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 28 '22 at 15:58