Skip to content
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

WIP: use get_feature_names_out from new sklearn if possible #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion mne_features/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def get_feature_names(self):
else:
return np.arange(self.output_shape_).astype(str)

def get_feature_names_out(self, input_features=None):
"""Mapping of the feature indices to feature names."""
return self.get_feature_names()

def get_params(self, deep=True):
"""Get the parameters (if any) of the given feature function.

Expand Down Expand Up @@ -219,7 +223,10 @@ def _apply_extractor(extractor, X, ch_names, return_as_df):
X = extractor.fit_transform(X)
feature_names = None
if return_as_df:
feature_names = extractor.get_feature_names()
if hasattr(extractor, 'get_feature_names_out'):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe changing the 4 lines with just:
feature_names = extractor.get_feature_names_out()
will increase code coverage ? (if this is the issue why not merging the PR)

feature_names = extractor.get_feature_names_out()
else:
feature_names = extractor.get_feature_names()
if ch_names is not None: # rename channels
mapping = {'ch%s' % i: ch_name
for i, ch_name in enumerate(ch_names)}
Expand Down