Как я могу получить имя каждой переменной после make_column_transformer ()? - PullRequest
0 голосов
/ 09 мая 2020

Как я могу получить имя каждой переменной после make_column_transformer (StandardScaler() , OneHotEncoder())?

num_cols=["Pclass","Age","SibSp","Parch", "Fare"]
cat_cols=["Sex", "Embarked"]

transformer_num_cols=make_pipeline(SimpleImputer(strategy = 'median'), StandardScaler())
transformer_cat_cols=make_pipeline(SimpleImputer(strategy="most_frequent"),OneHotEncoder())

preprocessor= make_column_transformer( (transformer_num_cols, num_cols),
                                       (transformer_cat_cols, cat_cols))

preprocessor.fit_transform(X_train)

preprocessor.get_feature_names()

preprocessor.get_feature_names()
AttributeError: Transformer pipeline-1 (type Pipeline) does not provide get_feature_names.

pd.DataFrame(preprocessor.fit_transform(X_train), columns= Total_columns)
...