Skip to content

GridSearchCV multiprocess (n_jobs=-1) high verbose not working in Jupyter notebook #22291

@darrencl

Description

@darrencl

Describe the bug

In Jupyter notebook, high verbosity, e.g. verbose=10 is currently not working when setting the multiprocessing, e.g. n_jobs=-1. It seems the output I got were only from the main thread/process, i.e.

Fitting 150 folds for each of 16 candidates, totalling 2400 fits

image

The output from process was not propagated correctly. This, strangely, does not happen in the iPython.
image

Just to be exact, they both use the same python and sklearn version.
image

Is there any way to check the progress on the current version? in Jupyter notebook?

Steps/Code to Reproduce

from sklearn import datasets
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import LeaveOneOut

iris = datasets.load_iris()

param_grid = {
    'criterion': ['gini', 'entropy'],
    'max_depth': range(2,10)
}
cv = GridSearchCV(
    estimator=DecisionTreeClassifier(random_state=42), param_grid=param_grid, n_jobs=-1, verbose=10, cv=LeaveOneOut()
)
cv.fit(iris.data, iris.target)

Expected Results

This is the output I'd expect. The example below is only using n_jobs=1, e.g.

Fitting 150 folds for each of 16 candidates, totalling 2400 fits
[CV 1/150; 1/16] START criterion=gini, max_depth=2..............................
[CV 1/150; 1/16] END criterion=gini, max_depth=2;, score=1.000 total time=   0.0s
[CV 3/150; 1/16] START criterion=gini, max_depth=2..............................
[CV 3/150; 1/16] END criterion=gini, max_depth=2;, score=1.000 total time=   0.0s

Actual Results

Only

Fitting 150 folds for each of 16 candidates, totalling 2400 fits

Versions

System:
    python: 3.7.6 | packaged by conda-forge | (default, Jan  7 2020, 22:33:48)  [GCC 7.3.0]
executable: /home/darren/anaconda3/bin/python
   machine: Linux-5.4.0-94-generic-x86_64-with-debian-bullseye-sid

Python dependencies:
          pip: 20.3.1
   setuptools: 45.1.0.post20200119
      sklearn: 1.0.2
        numpy: 1.19.1
        scipy: 1.5.2
       Cython: 0.29.21
       pandas: 1.2.2
   matplotlib: 3.2.1
       joblib: 0.14.1
threadpoolctl: 2.1.0

Built with OpenMP: True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions