-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] ENH validate sample_weight with _check_sample_weight in IsotonicRegression #16203
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @marijavlajic
sample_weight = np.ones(len(y), dtype=y.dtype) | ||
else: | ||
sample_weight = np.array(sample_weight[order], dtype=y.dtype) | ||
sample_weight = _check_sample_weight(sample_weight, y, dtype=y.dtype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
You need to apply the order
parameter, maybe as,
if sample_weight is None:
sample_weight = np.ones(len(y), dtype=y.dtype)
else:
sample_weight = _check_sample_weight(sample_weight, y, dtype=y.dtype)
sample_weight = sample_weight[order]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you think
sample_weight = _check_sample_weight(sample_weight, y, dtype=y.dtype)
sample_weight = sample_weight[order]
is enough ? It makes the code simpler and reordering ones has no effect and efficiency is not a problem there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes the code simpler and reordering ones has no effect and efficiency is not a problem there.
If you prefer. Slicing an array with int indexing does have some cost, but it should indeed be minimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the same :)
It has been done in #16322. Sorry @marijavlajic for the confusion but someone did the same thing and his PR got merged first. We still need to be better in coordination :/ |
Reference Issues/PRs
Fixes #15358 for IsotonicRegression.
What does this implement/fix? Explain your changes.
Replaces custom validation logic with standardized method utils.validation._check_sample_weight.
Any other comments?
Worked with @gelavizh1 @lschwetlick at scikit-learn sprint.
Worked also on the same issue in naive_bayes.py / for BaseDiscreteNB but it looks like the appropriate changes have already been made.
CC @adrinjalali @noatamir #WiMLDS