Skip to content

MNT add n_features_in_ through the feature_extraction module #20180

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

jeremiedbb
Copy link
Member

Part of #19333

the feature_extraction module contains CountVectorizer, DictVectorizer, FeatureHasher, HashingVectorizer, PatchExtractor, TfidfTransformer and TfidfVectorizer. n_features_in_ is only relevant for the TfidfTransformer.

Copy link
Member Author

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

2 remarks

Comment on lines -507 to -514
# test idf transform with incompatible n_features
X = [[1, 1, 5],
[1, 1, 0]]
t3.fit(X)
X_incompt = [[1, 3],
[1, 3]]
with pytest.raises(ValueError):
t3.transform(X_incompt)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now checked through the common tests

Comment on lines 3124 to 3125
if ("2darray" not in tags["X_types"] and "sparse" not in tags["X_types"] or
tags["no_validation"]):
Copy link
Member Author

Choose a reason for hiding this comment

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

TfidfTransformer has tags["X_types"] = "sparse". I guess it does not hurt to allow it as well since sparse is 2d

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.

LGTM

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM!

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