-
Notifications
You must be signed in to change notification settings - Fork 651
Deprecate get_feature_names in favor of get_feature_names_out
#8480
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. | ||
| # SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| import numbers | ||
|
|
@@ -15,6 +15,7 @@ | |
| import cuml.internals.logger as logger | ||
| from cuml.common.sparse import csr_row_normalize_l1, csr_row_normalize_l2 | ||
| from cuml.feature_extraction._stop_words import ENGLISH_STOP_WORDS | ||
| from cuml.internals.mixins import DeprecatedGetFeatureNamesMixin | ||
|
|
||
| CUPY_SPARSE_DTYPES = [cp.float32, cp.float64, cp.complex64, cp.complex128] | ||
|
|
||
|
|
@@ -384,7 +385,7 @@ def _term_frequency(X): | |
| return term_freq["count"].values | ||
|
|
||
|
|
||
| class CountVectorizer(_VectorizerMixin): | ||
| class CountVectorizer(DeprecatedGetFeatureNamesMixin, _VectorizerMixin): | ||
| """ | ||
| Convert a collection of text documents to a matrix of token counts | ||
|
|
||
|
|
@@ -752,18 +753,21 @@ def inverse_transform(self, X): | |
| vocab = Series(self.vocabulary_) | ||
| return [vocab[X[i, :].indices] for i in range(X.shape[0])] | ||
|
|
||
| def get_feature_names(self): | ||
| """ | ||
| Array mapping from feature integer indices to feature name. | ||
| def get_feature_names_out(self, input_features=None): | ||
| """Get output feature names for transformation. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| input_features : array-like of str or None, default=None | ||
| Not used, present here for API consistency by convention. | ||
|
|
||
| Returns | ||
| ------- | ||
|
|
||
| feature_names : Series | ||
| A list of feature names. | ||
|
|
||
| feature_names_out : numpy.ndarray of str objects. | ||
| Transformed feature names. | ||
| """ | ||
| return self.vocabulary_ | ||
| # TODO: use `check_is_fitted` once this class subclasses from `Base` | ||
|
Member
Author
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. This TODO will also be handled shortly in a followup. |
||
| return self.vocabulary_.to_numpy(dtype=object) | ||
|
jcrist marked this conversation as resolved.
jcrist marked this conversation as resolved.
|
||
|
|
||
|
|
||
| class HashingVectorizer(_VectorizerMixin): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.