[MRG + 2] Print train scores in _fit_and_score - #12613
Conversation
|
Sorry guys, it's my first PR and have no idea how to solve that code coverage error... |
jnothman
left a comment
There was a problem hiding this comment.
These cases are already not covered by tests, so it might not be essential to cover them (although it would be better if they were). Tests can be added in sklearn/model_selection/tests/test_validation.py.
I don't see why we shouldn't just output this data if verbose=2 also, as long as return_train_score=True...
test coverage increased
|
looks good. maybe a test for multimetric would be nice? Don't have a strong opinion, though. |
tests cleaned using pytest parametrize
| try: | ||
| # e.g. unwrap memmapped scalars | ||
| score = score.item() | ||
| except ValueError: |
There was a problem hiding this comment.
I don't get what this has to do with the present pull request
There was a problem hiding this comment.
I was trying to improve test coverage. Not sure in what situation the item() method can fail (we're checking before that if the object has this method before calling it), that's why I removed that try-except. But can revert that change if you feel was correct (and add a test if you give me an example of how to make it fail)
There was a problem hiding this comment.
I don't know why it's useful really, and I don't know why it's not tested, but you can't just remove existing functionality...
There was a problem hiding this comment.
yeah sorry
@marctorrellas if you need help with test tell me I can help =)
@eamanu I would actually appreciate if you can revert my change and add a test for that .item() failure. Or just giving me an example of how to make that to fail in purpose. I mean, can do it totally artificially, but there's a comment there "unwrap memapped scalars" and probably the tests should use that but no clue what it is
There was a problem hiding this comment.
Blame shows this commit:
amueller@a08555a
which is not very helpful.
I had assumed this was for dask support, but it would be weird if it was introduced in that PR.
If neither @jnothman nor I know why it's there it's a bit suspect but I wouldn't worry about it for this PR.
|
@marctorrellas if you need help with test tell me I can help =) |
|
I think this is ready for merge |
|
Please add a brief entry to the change log at |
Not really sure if I took the correct labels. Are |
|
I don't think API is right, just Enhancement probably? |
| `return_train_scores` is True and `verbose` > 2. | ||
| :issue:`12613` by :user:`Marc Torrellas <marctorrellas>`. | ||
|
|
||
| - |API| Additional tests for :func:`_fit_and_score` and :func:`_score`. |
There was a problem hiding this comment.
I would just remove this item tbh.
|
sweet, thanks! |
|
The what's new entry would avoid referring to private API. It should
instead mention affected estimators or public functions. Please submit a pr
fixing this. Thanks
|
sorry for that, see #12669 |
* print train scores when verbose > 3 in _fit_and_score * train_scores computed if verbose > 3, and 3 decimals places only * flake8 warnings solved * print train score if return_train_score test coverage increased * added test for multimetric; tests cleaned using pytest parametrize * fixing failed tests for python2... * revert changes in _scorer * modified whats_new * modified whats_new again
* print train scores when verbose > 3 in _fit_and_score * train_scores computed if verbose > 3, and 3 decimals places only * flake8 warnings solved * print train score if return_train_score test coverage increased * added test for multimetric; tests cleaned using pytest parametrize * fixing failed tests for python2... * revert changes in _scorer * modified whats_new * modified whats_new again
This small feature was first mentioned (afaik) in Issue #12598
What does this implement/fix? Explain your changes.
It is a simple change in
_fit_and_scoreallowing to print both train and test scores. This is used for different purposes: cross-validation (with any kind of splitter: Kfold, etc), grid/random search, learning curves. I also modified the format so that 3 decimals places are printed onlyAny other comments?
There was no documentation for the different verbosity levels, so I left the docstring untouched. Happy to explain what the different levels print if required