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

Skip to content

[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

Merged

Conversation

ritalulu
Copy link
Contributor

@ritalulu ritalulu commented Nov 2, 2019

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

@ritalulu ritalulu changed the title Fix: Use _check_sample_weight in BaseForest [MRG] Use _check_sample_weight in BaseForest Nov 2, 2019
@@ -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)
Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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 :)

@@ -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". \
Copy link
Member

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.")

% self.class_weight)
if self.warm_start:
warn('class_weight presets "balanced" or "balanced_subsample" are '
warn('class_weight presets "balanced" or \
Copy link
Member

Choose a reason for hiding this comment

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

Same here, avoid \

Copy link
Member

@adrinjalali adrinjalali left a 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

Comment on lines 559 to 560
'"balanced" weights, use compute_class_weight\
("balanced", '
Copy link
Member

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.

@adrinjalali
Copy link
Member

still have linting issues. You can run ./build_tools/circle/linting.sh from your scikit-learn's root folder and see the issues locally. You'll need flake8 installed.

@qinhanmin2014 qinhanmin2014 merged commit 0170009 into scikit-learn:master Nov 12, 2019
panpiort8 pushed a commit to panpiort8/scikit-learn that referenced this pull request Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants