python - 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)])
解决方案
推荐阅读
- python - 从字典列表创建 DataFrame 时指定列的顺序
- r - R函数在数据框中找到对象的最佳排名?
- r - 如何修复具有多个条件和 if 语句的 grepl 函数?
- javascript - 停止从子组件触发父组件波纹
- python - 如何解释 sklearn.feature_selection 中多类的 _coeffs 输出的特征的重要性?
- linq-to-entities - 如何从表 1 中仅选择在表 2 中具有相同值的行(C# - 实体框架到实体
- android - 自从升级到 Robolectric 4.3 后,ListView 的 onItemClickListener 得到一个空视图
- python - 无法使用 jupyter 在虚拟环境中工作
- python - 从另一个 SQL 数据库创建一个 SQL 数据库时内存使用过多
- javascript - 如何根据javascript中的值将空白元素添加到数组中