Как предлагается во многих других публикациях, например
существуют способы извлечения соответствующих имен функций. Однако как мне убедиться, что имена функций выровнены/находятся в том же порядке, что и
Код: Выделить всё
model.coef_
The structure I have is like:
Код: Выделить всё
num1_pre = Pipeline([ ... ])
num2_pre = Pipeline([ ... ])
cat1_pre = Pipeline([("cat_encode", OneHotEncoder())])
cat2_pre = Pipeline([("cat_encode", OrdinalEncoder()) ])
preprocessor = ColumnTransformer([
("num1_pre", num1_pre, num_col1),
("num2_pre", num2_pre, num_col2),
("cat1_pre", cat1_pre, cat_col1),
("cat2_pre", cat2_pre, cat_col2)
])
pipeline = Pipeline(steps=[
("preprocessor", preprocessor),
("poly_features", PolynomialFeatures(interaction_only=True, include_bias=False)),
("scaler", StandardScaler()),
("model", LinearRegression())
])
Код: Выделить всё
get_feature_names_out()
Код: Выделить всё
model = grid_search.best_estimator_
model[:-2].get_feature_names_out()
Источник: https://stackoverflow.com/questions/781 ... ture-oneho