-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] Use _check_sample_weight in BaseForest #15492
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
[MRG] Use _check_sample_weight in BaseForest #15492
Conversation
@@ -249,8 +249,7 @@ def decision_path(self, X): | |||
X = self._validate_X_predict(X) | |||
indicators = Parallel(n_jobs=self.n_jobs, verbose=self.verbose, | |||
**_joblib_parallel_args(prefer='threads'))( | |||
delayed(tree.decision_path)(X, | |||
check_input=False) | |||
delayed(tree.decision_path)(X, check_input=False) |
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 for fixing all these cosmetic issues, but it adds some noise both to the review process and to the history of this file, and it may lead to unnecessary conflicts with other pull-requests.
Therefore, we usually prefer changing only the strict minimum.
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.
ok to merge or do you want to undo these?
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.
No strong feelings, just wanted to mention it to avoid it in the future.
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.
that's what I figured, just wanted to confirm :)
sklearn/ensemble/_forest.py
Outdated
@@ -548,13 +548,16 @@ def _validate_y_class_weight(self, y): | |||
if isinstance(self.class_weight, str): | |||
if self.class_weight not in valid_presets: | |||
raise ValueError('Valid presets for class_weight include ' | |||
'"balanced" and "balanced_subsample". Given "%s".' | |||
'"balanced" and "balanced_subsample". \ |
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.
If we are to keep these changes, I think we prefer to avoid backslashes \
.
For strings you can close the string and reopen it below:
raise ValueError("blah \
blah.")
# can be rewritten into
raise ValueError("blah "
"blah.")
sklearn/ensemble/_forest.py
Outdated
% self.class_weight) | ||
if self.warm_start: | ||
warn('class_weight presets "balanced" or "balanced_subsample" are ' | ||
warn('class_weight presets "balanced" or \ |
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.
Same here, avoid \
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.
otherwise LGTM, thanks @ritalulu
sklearn/ensemble/_forest.py
Outdated
'"balanced" weights, use compute_class_weight\ | ||
("balanced", ' |
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.
the same comment regarding \
applies here.
still have linting issues. You can run |
Reference Issues/PRs
#15358
What does this implement/fix? Explain your changes.
Use _check_sample_weight to validate sample_weight in BaseForest.
Fixes trailing whitespace issues marked by flake8.
Worked on during the WIMLDS Bay Area Sprint with @lakrish