Skip to content

Commit

Permalink
API: use get_feature_names_out from new sklearn if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
agramfort committed Mar 27, 2022
1 parent 399092a commit 7abf7b4
Showing 1 changed file with 8 additions and 1 deletion.
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'):
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

0 comments on commit 7abf7b4

Please sign in to comment.