[MRG] ENH validate sample_weight with _check_sample_weight in IsotonicRegression#16203
Closed
marijavlajic wants to merge 2 commits intoscikit-learn:masterfrom
marijavlajic:check_weights
Closed
[MRG] ENH validate sample_weight with _check_sample_weight in IsotonicRegression#16203marijavlajic wants to merge 2 commits intoscikit-learn:masterfrom marijavlajic:check_weights
marijavlajic wants to merge 2 commits intoscikit-learn:masterfrom
marijavlajic:check_weights
Conversation
rth
reviewed
Jan 27, 2020
| 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) |
Member
There was a problem hiding this comment.
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]
Member
There was a problem hiding this comment.
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.
Member
There was a problem hiding this comment.
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.
Member
|
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 :/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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