-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] Standardize sample weights validation in DummyClassifier #15510
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ def fit(self, X, y, sample_weight=None): | |
|
||
self.n_outputs_ = y.shape[1] | ||
|
||
check_consistent_length(X, y, sample_weight) | ||
check_consistent_length(X, y) | ||
|
||
if sample_weight is not None: | ||
sample_weight = _check_sample_weight(sample_weight, X) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually it looks like several PRs were done for this estimator as this was added on the line below in #15505. Please remove the above 3 lines. Otherwise LGTM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth merging at this point? Looks like the only changes left would be one linting issue and removing sample weight from check_consistent_length. Does it make more sense to close the PR instead? |
||
|
@@ -245,7 +245,7 @@ def predict(self, X): | |
classes_ = [np.array([c]) for c in constant] | ||
|
||
y = _random_choice_csc(n_samples, classes_, class_prob, | ||
self.random_state) | ||
self.random_state) | ||
else: | ||
if self._strategy in ("most_frequent", "prior"): | ||
y = np.tile([classes_[k][class_prior_[k].argmax()] for | ||
|
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 think we might still want it here, not strong opinion, though...
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.
even though it's checked as part of the added validation?
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.
+1 to avoid redundant checks (even if it doesn't cost much).
_check_sample_weight
should yield better error messages