8000 [MRG] ENH Add get_feature_names for Binarizer by yenchenlin · Pull Request #6432 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG] ENH Add get_feature_names for Binarizer #6432

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions sklearn/preprocessing/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,23 @@ def __init__(self, threshold=0.0, copy=True):
self.threshold = threshold
self.copy = copy

def get_feature_names(self, input_features=None):
"""
Return feature names for output features

Parameters
----------
input_features : list of string, length len(input_features), optional
String names for input features if available. By default,
None is used.

Returns
-------
output_feature_names : list of string, length len(input_features)

"""
return input_features

def fit(self, X, y=None):
"""Do nothing and return the estimator unchanged

Expand Down
6 changes: 6 additions & 0 deletions sklearn/preprocessing/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,12 @@ def test_binarizer():
assert_raises(ValueError, binarizer.transform, sparse.csc_matrix(X))


def test_binarizer_feature_names():
binarizer = Binarizer()
feature_names = binarizer.get_feature_names(["a", "b", "c"])
assert_array_equal(['a', 'b', 'c'], feature_names)


def test_center_kernel():
# Test that KernelCenterer is equivalent to StandardScaler
# in feature space
Expand Down
0