首页 > 解决方案 > getting attributes from model pipeline with nested pipeline and columntransformer

问题描述

I've built a pipeline for a model which includes some preprocessing that is taken care of with another pipeline. After fitting the model, how can I access the parameters of these? Is it possible? I'm particularly interested in the components_ of pca and categories_ of ohe. Thanks for any hint.

num_pipe = Pipeline([('scaler', StandardScaler()),
                         ('knn_imputer', KNNImputer(weights="uniform", n_neighbors = 3)),
                        ('pca', PCA(n_components = 0.8))])

# build transformers
col_trans = ColumnTransformer(transformers = [('num_pipe', num_pipe, num_cols),
                                              ('ohe', OneHotEncoder(sparse=True, handle_unknown='ignore'), cat_cols),
                                              ('m_bin', MultiHotEncoder(), m_bin_cols)], remainder='drop')

model_log_pipe = Pipeline([('preprocessing', col_trans), ('model', model_log)])

标签: pythonpipeline

解决方案


推荐阅读