Native Feature Names
Scikit-learn 1.0 introduces native feature name support via get_feature_names_out(). Transformers propagate column names through pipelines, eliminating the need to manually track mappings.
Pipeline Example
python
import pandas as pd
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
df = pd.DataFrame({
'age': [25, 30, 35],
'salary': [30000, 50000, 70000],
'city': ['Paris', 'Lyon', 'Paris'],
})
ct = ColumnTransformer([
('num', StandardScaler(), ['age', 'salary']),
('cat', OneHotEncoder(), ['city']),
])
ct.fit(df)
print(ct.get_feature_names_out())
# ['num__age', 'num__salary', 'cat__city_Lyon', 'cat__city_Paris']
