8000 SimpleImputer does not implement `get_feature_names_out` · Issue #23733 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

SimpleImputer does not implement get_feature_names_out #23733

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
eric-czech opened this issue Jun 22, 2022 · 1 comment
Closed

SimpleImputer does not implement get_feature_names_out #23733

eric-czech opened this issue Jun 22, 2022 · 1 comment
Labels
Needs Triage Issue requires triage New Feature

Comments

@eric-czech
Copy link

Describe the workflow you want to enable

I noticed that SimpleImputer is still not supporting get_feature_names_out. In looking at issues like #21308 and #21688, I got the impression this may have been an oversight -- particularly since it looks like it's easy to fix this with _OneToOneFeatureMixin.

Is this just an omission or is there more to why that was not yet included? I couldn't find any other issues speaking to the latter.

Describe your proposed solution

Add _OneToOneFeatureMixin to SimpleImputer.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

@eric-czech eric-czech added Needs Triage Issue requires triage New Feature labels Jun 22, 2022
@thomasjpfan
Copy link
Member

SimpleImputer defines get_feature_names_out here: (It requires a custom implementation because it is not always one to one)

def get_feature_names_out(self, input_features=None):
"""Get output feature names for transformation.

With scikit-learn 1.1, the following works:

import numpy as np
from sklearn.impute import SimpleImputer
import pandas as pd

X = pd.DataFrame([[7, 2, 3], [4, np.nan, 6], [10, 5, 9]], columns=["feat1", "feat2", "feat3"])
imp_mean = SimpleImputer(missing_values=np.nan, strategy='mean')
imp_mean.fit(X)

print(imp_mean.get_feature_names_out())
# ['feat1' 'feat2' 'feat3']

4E9F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Triage Issue requires triage New Feature
Projects
None yet
Development

No branches or pull requests

2 participants
0