Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX potential AttributeError when passing list to ValidationCurveDisplay - #27311

Merged
glemaitre merged 15 commits into
scikit-learn:mainfrom
ArturoAmorQ:fix_AttributeError
Sep 13, 2023
Merged

FIX potential AttributeError when passing list to ValidationCurveDisplay#27311
glemaitre merged 15 commits into
scikit-learn:mainfrom
ArturoAmorQ:fix_AttributeError

Conversation

@ArturoAmorQ

Copy link
Copy Markdown
Member

Reference Issues/PRs

What does this implement/fix? Explain your changes.

Passing a list to the param_range parameter in ValidationCurveDisplay may rise a hard to debug

AttributeError: 'list' object has no attribute 'min'

if the spacing in the grid looks appropriate to use a "symlog" according to the current logic in the private function _interval_max_min_ratio.

Hopefully this PR fixes it.

Any other comments?

@github-actions

github-actions Bot commented Sep 7, 2023

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 705d37c. Link to the linter CI: here

@glemaitre

Copy link
Copy Markdown
Member

I prefer to validate _param_range in l. 894 when constructing the display. We documented that is should be a ndarray already and this parameter should not be passed directly to the constructor.

So we can have

    param_range=np.array(param_range, copy=False)

We will need a non-regression test as well that call the display by passing a list as param_range.
I think it could be nice to have this fix in 1.3.1

@glemaitre glemaitre added this to the 1.3.1 milestone Sep 8, 2023
@glemaitre
glemaitre removed their request for review September 8, 2023 18:31

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR. Was this already a bug in scikit-learn 1.3 or was this a bug in a new option first introduced for scikit-learn 1.4?

If the former, we need a dedicated changelog entry.

Comment thread sklearn/model_selection/_plot.py
Comment thread sklearn/model_selection/tests/test_plot.py Outdated
Comment thread sklearn/model_selection/tests/test_plot.py Outdated
@glemaitre
glemaitre self-requested a review September 12, 2023 14:18

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should solve the CIs issues.

Comment thread sklearn/model_selection/_plot.py Outdated
Comment thread sklearn/model_selection/_plot.py Outdated
Co-authored-by: Guillaume Lemaitre <[email protected]>
@ArturoAmorQ

Copy link
Copy Markdown
Member Author

We have the unrelated test_validation_curve_display_default_usage failing.

@glemaitre

Copy link
Copy Markdown
Member

This is a related failure :)
The tests assumed to store a list and == does not work with arrays.
Here, I think we can update it with

assert_array_equal(display.param_range, param_range)

Comment thread doc/whats_new/v1.4.rst Outdated
Comment thread sklearn/model_selection/tests/test_plot.py Outdated
@glemaitre
glemaitre merged commit 4b35216 into scikit-learn:main Sep 13, 2023
@glemaitre

Copy link
Copy Markdown
Member

Merging since the previous build already passed.

@ArturoAmorQ
ArturoAmorQ deleted the fix_AttributeError branch September 13, 2023 11:56
glemaitre added a commit to glemaitre/scikit-learn that referenced this pull request Sep 18, 2023
…lay (scikit-learn#27311)

Co-authored-by: ArturoAmorQ <[email protected]>
Co-authored-by: Olivier Grisel <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
jeremiedbb pushed a commit that referenced this pull request Sep 20, 2023
…lay (#27311)

Co-authored-by: ArturoAmorQ <[email protected]>
Co-authored-by: Olivier Grisel <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
…lay (scikit-learn#27311)

Co-authored-by: ArturoAmorQ <[email protected]>
Co-authored-by: Olivier Grisel <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
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.

4 participants