Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ENH Adds n_features_in_ to ensemble module #19326

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
merged 20 commits into from
Feb 22, 2021

Conversation

lorentzenchr
Copy link
Member

@lorentzenchr lorentzenchr commented Feb 1, 2021

Reference Issues/PRs

Continues #18514 and #19333.

@lorentzenchr lorentzenchr changed the title [WIP] ENH Adds n_features_in_ to ensemble module [MRG] ENH Adds n_features_in_ to ensemble module Feb 4, 2021
@lorentzenchr
Copy link
Member Author

Can someone help me out with the CI error?

sklearn/ensemble/_bagging.py Outdated Show resolved Hide resolved
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Minor comment, otherwise LGTM!

@@ -73,8 +73,9 @@ def __init__(self,
self.random_state = random_state

def _check_X(self, X):
return check_array(X, accept_sparse=['csr', 'csc'], ensure_2d=True,
allow_nd=True, dtype=None)
return self._validate_data(
Copy link
Member

Choose a reason for hiding this comment

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

I had to double check that _check_X was only called during non-fit methods. I think leaving a comment here would be best for now.

def _check_X(self, X):
	# Only called to validate `X` in non-`fit` methods.

@glemaitre glemaitre changed the title [MRG] ENH Adds n_features_in_ to ensemble module ENH Adds n_features_in_ to ensemble module Feb 11, 2021
@glemaitre glemaitre self-requested a review February 11, 2021 11:31
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM apart of the single nitpick

sklearn/ensemble/_bagging.py Outdated Show resolved Hide resolved
sklearn/ensemble/_bagging.py Outdated Show resolved Hide resolved
sklearn/ensemble/_bagging.py Outdated Show resolved Hide resolved
sklearn/ensemble/_forest.py Outdated Show resolved Hide resolved
sklearn/ensemble/_forest.py Outdated Show resolved Hide resolved
@@ -2421,7 +2449,7 @@ def fit_transform(self, X, y=None, sample_weight=None):
X_transformed : sparse matrix of shape (n_samples, n_out)
Transformed dataset.
"""
X = check_array(X, accept_sparse=['csc'])
X = self._validate_data(X, accept_sparse=['csc'])
Copy link
Member

Choose a reason for hiding this comment

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

Uhm what is the reason that the common test where not failing for this transformer since we did not introduce _validate_data before

Copy link
Member Author

Choose a reason for hiding this comment

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

test_check_n_features_in_after_fitting is applied to all estimators except those from modules listed in N_FEATURES_IN_AFTER_FIT_MODULES_TO_IGNORE. Every module where we add n_features_in_ has to be removed from that list. This is done in this PR form ensemble.

Or do you think of another test?

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking about check_n_features_in(name, estimator_orig) but I can check on the side.
Sorry we merged a new PR that added some conflicts in test_bagging again.

sklearn/ensemble/_gb.py Outdated Show resolved Hide resolved
sklearn/ensemble/_gb.py Outdated Show resolved Hide resolved
sklearn/ensemble/_gb.py Outdated Show resolved Hide resolved
sklearn/ensemble/_iforest.py Outdated Show resolved Hide resolved
@glemaitre glemaitre self-requested a review February 11, 2021 20:54
@lorentzenchr
Copy link
Member Author

@glemaitre Thanks for merging main. I had not seen merge conflicts here on github.

@glemaitre glemaitre merged commit 6852e31 into scikit-learn:main Feb 22, 2021
@lorentzenchr lorentzenchr deleted the n_features_ensemble branch February 22, 2021 21:17
@glemaitre glemaitre mentioned this pull request Apr 22, 2021
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.