EducationalTestingService / skll

SciKit-Learn Laboratory (SKLL) makes it easy to run machine learning experiments.
http://skll.readthedocs.org
Other
550 stars 69 forks source link

Add class method to learner object for retrieving feature names #714

Closed remo-help closed 1 year ago

remo-help commented 2 years ago

Learners with a selector potentially have a smaller feature name size than is stored in the feature_vectorizer. A simple method accessing the actual used feature names for a learner with or without a selector would be useful

def get_feature_names(self):
    if self.feat_selector:
        return self.feat_vectorizer.get_feature_names_out()[self.feat_selector.get_support()]
    else:
        return self.feat_vectorizer.get_feature_names_out()