Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
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
16 changes: 16 additions & 0 deletions sklearn/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ def named_steps(self):
def _final_estimator(self):
return self.steps[-1][1]

def get_feature_names(self):
Copy link
Member

Choose a reason for hiding this comment

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

I guess we should use if_delegate_has_method as below instead of the AttributeError here.

"""Get feature names from last step in pipeline

Returns
-------
feature_names : list of strings
Names of the features produced by last step in transform.
"""
last_step = self.steps[-1]
transformer = last_step[1]
name = last_step[0]
if not hasattr(transformer, 'get_feature_names'):
raise AttributeError("Transformer %s does not provide"
" get_feature_names." % str(name))
return transformer.get_feature_names()

# Estimator interface

def _pre_transform(self, X, y=None, **fit_params):
Expand Down