Skip to content

[MRG] ENH Show split/candidate ids in verbose output of SearchCV #16935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Jun 19, 2020

Conversation

cmarmo
Copy link
Contributor

@cmarmo cmarmo commented Apr 15, 2020

Reference Issues/PRs

Continue and close #8281

What does this implement/fix? Explain your changes.

Address @TomDLT comments.

Any other comments?

This PR is in the 0.23 milestone, I don't know if this is still needed, I just like the idea that perhaps he would have been happy to see this PR merged.

@cmarmo
Copy link
Contributor Author

cmarmo commented Apr 18, 2020

The example in #8281:

from sklearn import svm, datasets
from sklearn.model_selection import GridSearchCV

verbose=2
iris = datasets.load_iris()
parameters = {'kernel':('linear', 'rbf'), 'C':[1, 10]}
svr = svm.SVC()
clf = GridSearchCV(svr, parameters, n_jobs=8, verbose=verbose)
clf.fit(iris.data, iris.target)

gives:
verbose = 1

Fitting 5 folds for each of 4 candidates, totalling 20 fits

verbose = 2

Fitting 5 folds for each of 4 candidates, totalling 20 fits
[CV] START C=1, kernel='rbf'....................................................
[CV] END ..................................C=1, kernel='rbf'; total time=   0.0s
[CV] START C=1, kernel='linear'.................................................
[CV] START C=1, kernel='linear'.................................................
[CV] END ...............................C=1, kernel='linear'; total time=   0.0s
[CV] END ...............................C=1, kernel='linear'; total time=   0.0s
[CV] START C=1, kernel='linear'.................................................
[CV] START C=1, kernel='rbf'....................................................
[CV] END ..................................C=1, kernel='rbf'; total time=   0.0s
[CV] END ...............................C=1, kernel='linear'; total time=   0.0s
[CV] START C=1, kernel='rbf'....................................................
[CV] END ..................................C=1, kernel='rbf'; total time=   0.0s
[CV] START C=10, kernel='linear'................................................
[CV] START C=10, kernel='linear'................................................
[CV] END ..............................C=10, kernel='linear'; total time=   0.0s
[CV] START C=10, kernel='linear'................................................
[CV] END ..............................C=10, kernel='linear'; total time=   0.0s
[CV] START C=10, kernel='linear'................................................
[CV] START C=10, kernel='linear'................................................
[CV] END ..............................C=10, kernel='linear'; total time=   0.0s
[CV] START C=10, kernel='rbf'...................................................
[CV] END ..............................C=10, kernel='linear'; total time=   0.0s
[CV] START C=10, kernel='rbf'...................................................
[CV] END .................................C=10, kernel='rbf'; total time=   0.0s
[CV] START C=10, kernel='rbf'...................................................
[CV] END ..............................C=10, kernel='linear'; total time=   0.0s
[CV] START C=10, kernel='rbf'...................................................
[CV] END .................................C=10, kernel='rbf'; total time=   0.0s
[CV] END .................................C=10, kernel='rbf'; total time=   0.0s
[CV] START C=10, kernel='rbf'...................................................
[CV] END .................................C=10, kernel='rbf'; total time=   0.0s
[CV] END .................................C=10, kernel='rbf'; total time=   0.0s
[CV] START C=1, kernel='linear'.................................................
[CV] END ...............................C=1, kernel='linear'; total time=   0.0s
[CV] START C=1, kernel='rbf'....................................................
[CV] END ..................................C=1, kernel='rbf'; total time=   0.0s
[CV] START C=1, kernel='linear'.................................................
[CV] END ...............................C=1, kernel='linear'; total time=   0.0s
[CV] START C=1, kernel='rbf'....................................................
[CV] END ..................................C=1, kernel='rbf'; total time=   0.0s

verbose = 3

Fitting 5 folds for each of 4 candidates, totalling 20 fits
[CV 4/5] START C=1, kernel='linear'.............................................
[CV 4/5] END .......C=1, kernel='linear'; score: (test=0.967) total time=   0.0s
[CV 4/5] START C=1, kernel='rbf'................................................
[CV 4/5] END ..........C=1, kernel='rbf'; score: (test=0.933) total time=   0.0s
[CV 5/5] START C=1, kernel='rbf'................................................
[CV 5/5] END ..........C=1, kernel='rbf'; score: (test=1.000) total time=   0.0s
[CV 1/5] START C=10, kernel='linear'............................................
[CV 1/5] END ......C=10, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 2/5] START C=10, kernel='linear'............................................
[CV 2/5] END ......C=10, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 3/5] START C=10, kernel='linear'............................................
[CV 3/5] END ......C=10, kernel='linear'; score: (test=0.900) total time=   0.0s
[CV 4/5] START C=10, kernel='linear'............................................
[CV 4/5] END ......C=10, kernel='linear'; score: (test=0.967) total time=   0.0s
[CV 5/5] START C=10, kernel='linear'............................................
[CV 5/5] END ......C=10, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 1/5] START C=10, kernel='rbf'...............................................
[CV 1/5] END .........C=10, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 2/5] START C=10, kernel='rbf'...............................................
[CV 2/5] END .........C=10, kernel='rbf'; score: (test=1.000) total time=   0.0s
[CV 3/5] START C=10, kernel='rbf'...............................................
[CV 3/5] END .........C=10, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 4/5] START C=10, kernel='rbf'...............................................
[CV 4/5] END .........C=10, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 5/5] START C=10, kernel='rbf'...............................................
[CV 5/5] END .........C=10, kernel='rbf'; score: (test=1.000) total time=   0.0s
[CV 1/5] START C=1, kernel='linear'.............................................
[CV 1/5] END .......C=1, kernel='linear'; score: (test=0.967) total time=   0.0s
[CV 2/5] START C=1, kernel='linear'.............................................
[CV 2/5] END .......C=1, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 3/5] START C=1, kernel='linear'.............................................
[CV 3/5] END .......C=1, kernel='linear'; score: (test=0.967) total time=   0.0s
[CV 2/5] START C=1, kernel='rbf'................................................
[CV 2/5] END ..........C=1, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 1/5] START C=1, kernel='rbf'................................................
[CV 1/5] END ..........C=1, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 3/5] START C=1, kernel='rbf'................................................
[CV 3/5] END ..........C=1, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 5/5] START C=1, kernel='linear'.............................................
[CV 5/5] END .......C=1, kernel='linear'; score: (test=1.000) total time=   0.0s

verbose = 10

Fitting 5 folds for each of 4 candidates, totalling 20 fits
[CV 2/5; 1/4] START C=1, kernel='linear'........................................
[CV 2/5; 1/4] END ..C=1, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 4/5; 2/4] START C=1, kernel='rbf'...........................................
[CV 4/5; 2/4] END .....C=1, kernel='rbf'; score: (test=0.933) total time=   0.0s
[CV 5/5; 2/4] START C=1, kernel='rbf'...........................................
[CV 5/5; 2/4] END .....C=1, kernel='rbf'; score: (test=1.000) total time=   0.0s
[CV 1/5; 3/4] START C=10, kernel='linear'.......................................
[CV 1/5; 3/4] END .C=10, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 2/5; 3/4] START C=10, kernel='linear'.......................................
[CV 2/5; 3/4] END .C=10, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 3/5; 3/4] START C=10, kernel='linear'.......................................
[CV 3/5; 3/4] END .C=10, kernel='linear'; score: (test=0.900) total time=   0.0s
[CV 4/5; 3/4] START C=10, kernel='linear'.......................................
[CV 4/5; 3/4] END .C=10, kernel='linear'; score: (test=0.967) total time=   0.0s
[CV 5/5; 3/4] START C=10, kernel='linear'.......................................
[CV 5/5; 3/4] END .C=10, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 1/5; 4/4] START C=10, kernel='rbf'..........................................
[CV 1/5; 4/4] END ....C=10, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 2/5; 4/4] START C=10, kernel='rbf'..........................................
[CV 2/5; 4/4] END ....C=10, kernel='rbf'; score: (test=1.000) total time=   0.0s
[CV 3/5; 4/4] START C=10, kernel='rbf'..........................................
[CV 3/5; 4/4] END ....C=10, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 4/5; 4/4] START C=10, kernel='rbf'..........................................
[CV 4/5; 4/4] END ....C=10, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 5/5; 4/4] START C=10, kernel='rbf'..........................................
[CV 5/5; 4/4] END ....C=10, kernel='rbf'; score: (test=1.000) total time=   0.0s
[CV 1/5; 1/4] START C=1, kernel='linear'........................................
[CV 1/5; 1/4] END ..C=1, kernel='linear'; score: (test=0.967) total time=   0.0s
[CV 1/5; 2/4] START C=1, kernel='rbf'...........................................
[CV 1/5; 2/4] END .....C=1, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 4/5; 1/4] START C=1, kernel='linear'........................................
[CV 4/5; 1/4] END ..C=1, kernel='linear'; score: (test=0.967) total time=   0.0s
[CV 5/5; 1/4] START C=1, kernel='linear'........................................
[CV 5/5; 1/4] END ..C=1, kernel='linear'; score: (test=1.000) total time=   0.0s
[CV 3/5; 1/4] START C=1, kernel='linear'........................................
[CV 3/5; 1/4] END ..C=1, kernel='linear'; score: (test=0.967) total time=   0.0s
[CV 2/5; 2/4] START C=1, kernel='rbf'...........................................
[CV 2/5; 2/4] END .....C=1, kernel='rbf'; score: (test=0.967) total time=   0.0s
[CV 3/5; 2/4] START C=1, kernel='rbf'...........................................
[CV 3/5; 2/4] END .....C=1, kernel='rbf'; score: (test=0.967) total time=   0.0s

@cmarmo cmarmo changed the title [WIP] ENH Show split/candidate ids in verbose output of SearchCV [MRG] ENH Show split/candidate ids in verbose output of SearchCV Apr 18, 2020
@cmarmo
Copy link
Contributor Author

cmarmo commented Apr 19, 2020

I have removed the old verbosity test because the verbose behavior has changed. Let me know if this is not correct.

@cmarmo cmarmo changed the title [MRG] ENH Show split/candidate ids in verbose output of SearchCV [WIP] ENH Show split/candidate ids in verbose output of SearchCV Apr 19, 2020
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @cmarmo , made a quick review but looks good

(IDK if you don't know or just forgot but you can use syntax highlighting in github using

```py 
code here
```

)

@cmarmo
Copy link
Contributor Author

cmarmo commented Apr 19, 2020

(IDK if you don't know or just forgot but you can use syntax highlighting in github using

Thanks! :)

@jnothman
Copy link
Member

Personally I find showing both START and END (and params and score!) for each fit very verbose already. So I'm not sure that verbose is a very helpful control for users.

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but in terms of adding the feature, this is fine.

Please add an entry to the change log at doc/whats_new/v0.24.rst. Like the other entries there, please reference this pull request with :pr: and credit yourself (and other contributors if applicable) with :user:

@cmarmo
Copy link
Contributor Author

cmarmo commented May 22, 2020

Personally I find showing both START and END (and params and score!) for each fit very verbose already. So I'm not sure that verbose is a very helpful control for users.

I have removed the START thing from all levels except 10. So verbose 1 and 10 are as above.
verbose = 2 gives

Fitting 5 folds for each of 4 candidates, totalling 20 fits
[CV] END .................................C=1, kernel=linear; total time=   0.0s
[CV] END ....................................C=1, kernel=rbf; total time=   0.0s
[CV] END ....................................C=1, kernel=rbf; total time=   0.0s
[CV] END ................................C=10, kernel=linear; total time=   0.0s
[CV] END ................................C=10, kernel=linear; total time=   0.0s
[CV] END ................................C=10, kernel=linear; total time=   0.0s
[CV] END ................................C=10, kernel=linear; total time=   0.0s
[CV] END ................................C=10, kernel=linear; total time=   0.0s
[CV] END ...................................C=10, kernel=rbf; total time=   0.0s
[CV] END ...................................C=10, kernel=rbf; total time=   0.0s
[CV] END ...................................C=10, kernel=rbf; total time=   0.0s
[CV] END ...................................C=10, kernel=rbf; total time=   0.0s
[CV] END ...................................C=10, kernel=rbf; total time=   0.0s
[CV] END ....................................C=1, kernel=rbf; total time=   0.0s
[CV] END ....................................C=1, kernel=rbf; total time=   0.0s
[CV] END .................................C=1, kernel=linear; total time=   0.0s
[CV] END .................................C=1, kernel=linear; total time=   0.0s
[CV] END .................................C=1, kernel=linear; total time=   0.0s
[CV] END .................................C=1, kernel=linear; total time=   0.0s
[CV] END ....................................C=1, kernel=rbf; total time=   0.0s

verbose = 3 gives

Fitting 5 folds for each of 4 candidates, totalling 20 fits
[CV 1/5] END ............C=1, kernel=rbf; score: (test=0.967) total time=   0.0s
[CV 4/5] END ............C=1, kernel=rbf; score: (test=0.933) total time=   0.0s
[CV 5/5] END ............C=1, kernel=rbf; score: (test=1.000) total time=   0.0s
[CV 1/5] END ........C=10, kernel=linear; score: (test=1.000) total time=   0.0s
[CV 2/5] END ........C=10, kernel=linear; score: (test=1.000) total time=   0.0s
[CV 3/5] END ........C=10, kernel=linear; score: (test=0.900) total time=   0.0s
[CV 4/5] END ........C=10, kernel=linear; score: (test=0.967) total time=   0.0s
[CV 5/5] END ........C=10, kernel=linear; score: (test=1.000) total time=   0.0s
[CV 1/5] END ...........C=10, kernel=rbf; score: (test=0.967) total time=   0.0s
[CV 2/5] END ...........C=10, kernel=rbf; score: (test=1.000) total time=   0.0s
[CV 3/5] END ...........C=10, kernel=rbf; score: (test=0.967) total time=   0.0s
[CV 4/5] END ...........C=10, kernel=rbf; score: (test=0.967) total time=   0.0s
[CV 5/5] END ...........C=10, kernel=rbf; score: (test=1.000) total time=   0.0s
[CV 2/5] END .........C=1, kernel=linear; score: (test=1.000) total time=   0.0s
[CV 1/5] END .........C=1, kernel=linear; score: (test=0.967) total time=   0.0s
[CV 3/5] END .........C=1, kernel=linear; score: (test=0.967) total time=   0.0s
[CV 4/5] END .........C=1, kernel=linear; score: (test=0.967) total time=   0.0s
[CV 2/5] END ............C=1, kernel=rbf; score: (test=0.967) total time=   0.0s
[CV 5/5] END .........C=1, kernel=linear; score: (test=1.000) total time=   0.0s
[CV 3/5] END ............C=1, kernel=rbf; score: (test=0.967) total time=   0.0s

Let me know if this is satisfying or I should revert. Thanks!

@jnothman
Copy link
Member

jnothman commented May 24, 2020 via email

@cmarmo
Copy link
Contributor Author

cmarmo commented Jun 4, 2020

The check failure does not depend on my changes.

@cmarmo
Copy link
Contributor Author

cmarmo commented Jun 11, 2020

@NicolasHug maybe you are available to finalize this one? Thanks!

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well. I think all comments by other reviewers have been addressed. Merging.

Thank you very much @cmarmo!

@ogrisel ogrisel merged commit fc0d2c3 into scikit-learn:master Jun 19, 2020
@jnothman
Copy link
Member

jnothman commented Jun 21, 2020 via email

dsandeep0138 pushed a commit to dsandeep0138/scikit-learn that referenced this pull request Jun 21, 2020
@cmarmo cmarmo deleted the gridsearchcv_verbose_enh branch June 21, 2020 11:45
rubywerman pushed a commit to MLH-Fellowship/scikit-learn that referenced this pull request Jun 24, 2020
viclafargue pushed a commit to viclafargue/scikit-learn that referenced this pull request Jun 26, 2020
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants