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

Skip to content

FIX RidgeCV works with multioutput and sample-weight non-default score #29877

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

Conversation

glemaitre
Copy link
Member

This PR is fixing the following case:

  • RidgeCV with scoring != None
  • Passing some sample_weight
  • y should be multioutput

As stated in #29842 (comment), there is a bug. Previous to metadata routing, we did not use sample_weight for the scoring and we never encounter this bug.

Copy link

github-actions bot commented Sep 17, 2024

✔️ Linting Passed

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

Generated for commit: 3b3a034. Link to the linter CI: here

@glemaitre
Copy link
Member Author

OK so the reason is that we should not ravel the predictions and the true labels and only let the scorer the average. In this case, they all be "sample aligned" based on n_samples.

I added a non-regression test.

I don't think that we need to have an entry in the changelog since before we were not using sample_weight to compute the score (which was another bug).

@glemaitre
Copy link
Member Author

ping @OmarManzoor @StefanieSenger @adrinjalali that already have a good understanding if this part of the code.

FYI the original error would have been something like:

E           ValueError: Found input variables with inconsistent numbers of samples: [200, 200, 100]

because the raveling would transform the predictions and true label from a shape of (100, 2) to (200,) while the sample_weight is always an array of (100,).

@glemaitre
Copy link
Member Author

I can add an additional test by defining a custom scorer that would not do a simple uniform average between the target. In this case, it should fail in main but work in this PR.

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @glemaitre

@adrinjalali adrinjalali merged commit 25bc29a into scikit-learn:main Sep 18, 2024
33 of 34 checks passed
kbharat1210 pushed a commit to kbharat1210/scikit-learn that referenced this pull request Sep 25, 2024
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.

3 participants