You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GridSearchCV.verbose documentation does not match actual behavior (values >3, >10) #32946
verbose int
Controls the verbosity: the higher, the more messages.
>1 : the computation time for each fold and parameter candidate is displayed;
>2 : the score is also displayed;
>3 : the fold and candidate parameter indexes are also displayed together with the starting time of the computation.
In reality, this param is passed to joblib here, whose docs state:
verbose: int, default=0
The verbosity level: if non zero, progress messages are printed. Above 50, the output is sent to stdout. The frequency of the messages increases with the verbosity level. If it more than 10, all iterations are reported.
Testing with the MRE below shows that 0 is silent, 1 prints one line, 2 prints a line for each CV split. 3-9 are all the same. 10-inf are all the same
It is possible taht the same issue exists elsewhere, I've not looked thoroughly
Suggest a potential alternative/fix
Update docs to match observed behaviour, e.g.:
verbose int
Controls the verbosity: the higher, the more messages.
0 : no messages;
1 : a single line describing the number of folds, the number of candidates, and the number of fits;
2 : the above, plus when each fold ends, the computation time for that fold and parameter candidate is displayed;
3-9 : the above, plus the fold index and the score is also displayed;
≥10 : an additional message for the start of each fold, and the candidate parameter indexes are also displayed.
A useful feature would be to have a setting between the current 1 and 2 which prints a message for each param combination, but not for each fold. So it would print the params, and the mean score for each of the metrics over the folds. That would be the ideal setting for me which isn't currently supported. So perhaps this issue should change from the Documentation label to a New Feature Request?
I agree we can add some more information on the verbosity in the docs of GridSearchCV and RandomizedSearchCV. Mentioning that 0 is the default, what happens at 0 and possibly what is differentwith verbosity above 10, similar as you did but maybe a bit leaner.
Did you test this with a large dataset and can you verify if there is a gain in information between verbosity=3 and verbosity>10? Meaning, is there a delay between START and END? If so, it is worth documenting the verbosity>10 case, otherwise I don't think it's worth it.
If you are interested, please go ahead and make a PR.
A useful feature would be to have a setting between the current 1 and 2 which prints a message for each param combination, but not for each fold. So it would print the params, and the mean score for each of the metrics over the folds. That would be the ideal setting for me which isn't currently supported. So perhaps this issue should change from the Documentation label to a New Feature Request?
Some people are working on a callback API, that allows customised logging and progress bars, that, to my current understanding will allow you to log messages for param combinations. So what you are requesting is already being developed. :) (See #27676, if you are interested.)
Did you test this with a large dataset and can you verify if there is a gain in information between verbosity=3 and verbosity>10? Meaning, is there a delay between START and END?
Yes, there is a delay between START and END. You can confirm this using the MRE above by changing to
X, y=make_classification(n_samples=5_000_000)
which makes each fold take a second.
Thanks for the info about the callback Issue, that def sounds like a valuable addition to sklearn.
@anandvenugopal-tech - you expressed interest in making a PR for this doc change?
Hi @StefanieSenger , for the clarification.
Yes, I’m interested in making a documentation-only PR.
I’ll update the docs for both GridSearchCV and RandomizedSearchCV, keep it lean, and document only the observed behavior (including verbose=0 and the verbose > 10 case), without backend-specific guarantees.
Ups, just to clarify, I had actually intended to ask if there was a delay between END of the previous iteration and START of the next, and there isn't (at least not with the current example and n_samples=5_000_000).
But I have seen there actually IS some additional information between verbosity< 9 and verbosity>9 (which is not the additional START): the indices of the parameter candidates are then also displayed in [CV 2/2; 1/2]. It is the second set (1/2 here) which means index of param C (1) of total number of indices for param C (2).
So it is worth mentioning the option of verbosity=10 and higher.
======= verbose=9 =======
Fitting 2 folds for each of 2 candidates, totalling 4 fits
[CV 1/2] END ...............................C=1;, score=0.891 total time= 3.1s
[CV 2/2] END ...............................C=1;, score=0.890 total time= 2.4s
[CV 1/2] END ...............................C=2;, score=0.891 total time= 2.1s
[CV 2/2] END ...............................C=2;, score=0.890 total time= 2.0s
======= verbose=10 =======
Fitting 2 folds for each of 2 candidates, totalling 4 fits
[CV 1/2; 1/2] START C=1.........................................................
[CV 1/2; 1/2] END ..........................C=1;, score=0.891 total time= 4.2s
[CV 2/2; 1/2] START C=1.........................................................
[CV 2/2; 1/2] END ..........................C=1;, score=0.890 total time= 6.1s
[CV 1/2; 2/2] START C=2.........................................................
[CV 1/2; 2/2] END ..........................C=2;, score=0.891 total time= 3.7s
[CV 2/2; 2/2] START C=2.........................................................
[CV 2/2; 2/2] END ..........................C=2;, score=0.890 total time= 2.6s
Ups, just to clarify, I had actually intended to ask if there was a delay between END of the previous iteration and START of the next, and there isn't (at least not with the current example and n_samples=5_000_000).
Right, agreed.
But I have seen there actually IS some additional information between verbosity< 9 and verbosity>9 (which is not the additional START): the indices of the parameter candidates are then also displayed in [CV 2/2; 1/2]. It is the second set (1/2 here) which means index of param C (1) of total number of indices for param C (2). So it is worth mentioning the option of verbosity=10 and higher.
Right - I didn't explain this too well in my message but that is what I meant with "and the candidate parameter indexes are also displayed" in my suggested docs update
TBH it feels like verbose could be simplified. I'd also argue that which param candidate index is more important than which fold index, so that the progress of a large grid search can be tracked. I'd advocate for the output looking like
======= verbose=0 =======
======= verbose=1 =======
Fitting 2 folds for each of 2 candidates, totalling 4 fits
======= verbose=2 =======
Fitting 2 folds for each of 2 candidates, totalling 4 fits
- [CV] END ................................................C=1; total time= 0.0s- [CV] END ................................................C=1; total time= 0.0s- [CV] END ................................................C=2; total time= 0.0s- [CV] END ................................................C=2; total time= 0.0s+ [Cand 1/2] ............C=1; mean_score=0.900; std_score=0.02; total time= 0.0s+ [Cand 2/2] ............C=2; mean_score=0.950; std_score=0.03; total time= 0.0s
======= verbose=3 =======
Fitting 2 folds for each of 2 candidates, totalling 4 fits
- [CV 1/2] END ...............................C=1;, score=0.900 total time= 0.0s- [CV 2/2] END ...............................C=1;, score=0.900 total time= 0.0s- [CV 1/2] END ...............................C=2;, score=0.900 total time= 0.0s- [CV 2/2] END ...............................C=2;, score=0.900 total time= 0.0s+ [Cand 1/2, CV 1/2] ..........................C=1; score=0.900 total time= 0.0s+ [Cand 1/2, CV 2/2] ..........................C=1; score=0.900 total time= 0.0s+ [Cand 2/2, CV 1/2] ..........................C=2; score=0.900 total time= 0.0s+ [Cand 2/2, CV 2/2] ..........................C=2; score=0.900 total time= 0.0s
so only 0,1,2,3 are valid settings.
0 = silent (unchanged);
1 = one-liner overview (unchanged);
2 = tracking param combination candidates, with their mean scores (and possibly stds);
3 = tracking each split for each candidate.
When we track each candidate / split, we print all info about that candidate / split as we're anyway outputting a line about it and the extra info can't hurt. Those just seem like much more clearly defined options than what we have currently.
I guess it depends on whether there is appetite for changing behaviour vs simply fixing docs.
It felt the same to me. Though I am not sure about the historical or practical reasons of why the verbose output is the way it is. That would have to be researched.
I'd also argue that which param candidate index is more important than which fold index, so that the progress of a large grid search can be tracked.
Not sure I follow. We need to comply to the order of the training. The CV folds are in the outer loop and we cannot change their order. So an output like
doesn't seem possible, if we keep the verbosity logging-like (which we do want), so it gets displayed real time to track progress.
That doesn't mean the verbosity output could not be improved.
I guess it depends on whether there is appetite for changing behaviour vs simply fixing docs.
Yes, exactly. I think we can do the quick doc fix right now, and revise the verbose outputs in a subsequent PR. I am not sure if changing the verbosity right now will be an uncomplicated matter. There likely will be some discussion and exchange of opinions on a PR trying this, also with regard to the callback loggings. But maybe it's a straightforward thing. 🤷♀️
I'm happy to review a PR if you want to give it a try.
Good point - I'd not actually thought carefully about the order of the loops. From the output when verbose=10 I'd understood it looped over each param candidate and then over the splits - as it shows CVs 1&2 for candidate 1 (C=1), and only then CVs 1&2 for candidate 2 (C=2) - am I mistaken? This seems to be the relevant bit of code
for (cand_idx, parameters), (split_idx, (train, test)) inproduct(
enumerate(candidate_params),
enumerate(cv.split(X, y, **routed_params.splitter.split)),
)
if I understand itertools.product correctly, isn't the first arg used as the outer loop? Apologies if I'm misunderstanding
if we keep the verbosity logging-like (which we do want), so it gets displayed real time to track progress
fully agree, verbose output def needs to be in real time.
OK let's leave it as a docs change for now as you suggest 😃
I'd understood it looped over each param candidate and then over the splits
That is indeed true. I had thought the wrong way around but after checking the code I see you're right. The parallel execution of the _fit_and_score (li 999-1015) iterates over the params as the outer loop and then fits and scores on one split at the time. So the output you suggested would indeed be possible.
OK let's leave it as a docs change for now as you suggest 😃
Hi @StefanieSenger, thanks for the clarification.
I understand the final decision is to keep this as a documentation-only fix, clarifying the current verbose behavior (including verbose=0 and verbose >= 10) for both GridSearchCV and RandomizedSearchCV, without changing functionality.
Activity
Gabriel-Kissin commentedon Dec 25, 2025
A useful feature would be to have a setting between the current 1 and 2 which prints a message for each param combination, but not for each fold. So it would print the params, and the mean score for each of the metrics over the folds. That would be the ideal setting for me which isn't currently supported. So perhaps this issue should change from the Documentation label to a New Feature Request?
anandvenugopal-tech commentedon Dec 26, 2025
Hi, I’d like to work on improving the documentation for this issue.
Please let me know if that’s okay.
Gabriel-Kissin commentedon Dec 27, 2025
same issue with
RandomizedSearchCV.StefanieSenger commentedon Dec 29, 2025
Hi @Gabriel-Kissin, thanks for reporting.
I agree we can add some more information on the verbosity in the docs of
GridSearchCVandRandomizedSearchCV. Mentioning that 0 is the default, what happens at 0 and possibly what is differentwith verbosity above 10, similar as you did but maybe a bit leaner.Did you test this with a large dataset and can you verify if there is a gain in information between
verbosity=3andverbosity>10? Meaning, is there a delay betweenSTARTandEND? If so, it is worth documenting theverbosity>10case, otherwise I don't think it's worth it.If you are interested, please go ahead and make a PR.
Some people are working on a callback API, that allows customised logging and progress bars, that, to my current understanding will allow you to log messages for param combinations. So what you are requesting is already being developed. :) (See #27676, if you are interested.)
Gabriel-Kissin commentedon Dec 29, 2025
Thanks @StefanieSenger.
Yes, there is a delay between START and END. You can confirm this using the MRE above by changing to
which makes each fold take a second.
Thanks for the info about the callback Issue, that def sounds like a valuable addition to sklearn.
@anandvenugopal-tech - you expressed interest in making a PR for this doc change?
anandvenugopal-tech commentedon Dec 29, 2025
Hi @StefanieSenger , for the clarification.
Yes, I’m interested in making a documentation-only PR.
I’ll update the docs for both GridSearchCV and RandomizedSearchCV, keep it lean, and document only the observed behavior (including verbose=0 and the verbose > 10 case), without backend-specific guarantees.
StefanieSenger commentedon Dec 31, 2025
Ups, just to clarify, I had actually intended to ask if there was a delay between END of the previous iteration and START of the next, and there isn't (at least not with the current example and
n_samples=5_000_000).But I have seen there actually IS some additional information between
verbosity< 9andverbosity>9(which is not the additional START): the indices of the parameter candidates are then also displayed in[CV 2/2; 1/2]. It is the second set (1/2here) which means index of paramC(1) of total number of indices for paramC(2).So it is worth mentioning the option of verbosity=10 and higher.
Gabriel-Kissin commentedon Dec 31, 2025
Right, agreed.
Right - I didn't explain this too well in my message but that is what I meant with "and the candidate parameter indexes are also displayed" in my suggested docs update
TBH it feels like verbose could be simplified. I'd also argue that which param candidate index is more important than which fold index, so that the progress of a large grid search can be tracked. I'd advocate for the output looking like
so only 0,1,2,3 are valid settings.
When we track each candidate / split, we print all info about that candidate / split as we're anyway outputting a line about it and the extra info can't hurt. Those just seem like much more clearly defined options than what we have currently.
I guess it depends on whether there is appetite for changing behaviour vs simply fixing docs.
StefanieSenger commentedon Dec 31, 2025
It felt the same to me. Though I am not sure about the historical or practical reasons of why the verbose output is the way it is. That would have to be researched.
Not sure I follow. We need to comply to the order of the training. The CV folds are in the outer loop and we cannot change their order. So an output like
doesn't seem possible, if we keep the verbosity logging-like (which we do want), so it gets displayed real time to track progress.
That doesn't mean the verbosity output could not be improved.
Yes, exactly. I think we can do the quick doc fix right now, and revise the verbose outputs in a subsequent PR. I am not sure if changing the verbosity right now will be an uncomplicated matter. There likely will be some discussion and exchange of opinions on a PR trying this, also with regard to the callback loggings. But maybe it's a straightforward thing. 🤷♀️
I'm happy to review a PR if you want to give it a try.
Gabriel-Kissin commentedon Dec 31, 2025
Thanks @StefanieSenger
Good point - I'd not actually thought carefully about the order of the loops. From the output when
verbose=10I'd understood it looped over each param candidate and then over the splits - as it shows CVs 1&2 for candidate 1 (C=1), and only then CVs 1&2 for candidate 2 (C=2) - am I mistaken? This seems to be the relevant bit of codeif I understand itertools.product correctly, isn't the first arg used as the outer loop? Apologies if I'm misunderstanding
fully agree, verbose output def needs to be in real time.
OK let's leave it as a docs change for now as you suggest 😃
StefanieSenger commentedon Jan 2, 2026
That is indeed true. I had thought the wrong way around but after checking the code I see you're right. The parallel execution of the
_fit_and_score(li 999-1015) iterates over the params as the outer loop and then fits and scores on one split at the time. So the output you suggested would indeed be possible.I'm happy with this, too.
abhimanyu345 commentedon Jan 3, 2026
Hi @StefanieSenger, thanks for the clarification.
I understand the final decision is to keep this as a documentation-only fix, clarifying the current verbose behavior (including verbose=0 and verbose >= 10) for both GridSearchCV and RandomizedSearchCV, without changing functionality.
I’ll proceed with preparing a concise docs PR.
chaitanyakumar-d commentedon Jan 7, 2026
Hi! I'd like to work on this issue. Is it still available?
Gabriel-Kissin commentedon Jan 7, 2026
Closing as implemented in PR #32968 and merged in. Many thanks to all contributors