get_feature_names_out()
noun
say it: “GET FEE-cher NAYMZ OWT” /ˈɡɛt ˈfitʃər ˈneɪmz ˈaʊt/
In scikit-learn, the method that returns the names of the columns a fitted preparation step produces.
What does get_feature_names_out() do?
get_feature_names_out() names each column a fitted preparing step hands back, in order, such as species_cat and
species_dog from a OneHotEncoder. On a ColumnTransformer, each name starts with its part's name, such as
num__age. It's how you match coefficients and importances to columns.
from sklearn.preprocessing import OneHotEncoder
encoder = OneHotEncoder().fit([["dog"], ["cat"], ["rabbit"]])
print(encoder.get_feature_names_out(["species"])) # ['species_cat' 'species_dog' 'species_rabbit']
In a sentence
- “get_feature_names_out() showed the encoder had made species_cat, species_dog and species_rabbit.”
- “She paired coef_ with get_feature_names_out() to see which column each coefficient belonged to.”
Level: Freelancer · More Python terms at this level
Updated