相关疑难解决方法(0)

从scikit-learn管道获取模型属性

我通常得到这样的PCA负载:

pca = PCA(n_components=2)
X_t = pca.fit(X).transform(X)
loadings = pca.components_
Run Code Online (Sandbox Code Playgroud)

如果我PCA使用scikit-learnpipline 运行...

from sklearn.pipeline import Pipeline
pipeline = Pipeline(steps=[    
('scaling',StandardScaler()),
('pca',PCA(n_components=2))
])
X_t=pipeline.fit_transform(X)
Run Code Online (Sandbox Code Playgroud)

......有可能获得负荷吗?

只是尝试loadings = pipeline.components_失败:

AttributeError: 'Pipeline' object has no attribute 'components_'
Run Code Online (Sandbox Code Playgroud)

谢谢!

(也有兴趣coef_从学习管道中提取属性.)

python scikit-learn neuraxle

33
推荐指数
2
解决办法
2万
查看次数

从 Sklearn 管道中使用特征名称提取特征重要性

我想知道在预处理管道中使用分类器时,如何从 scikit-learn 中的随机森林中提取特征重要性以及特征名称。

这里的问题仅涉及提取特征重要性:如何从 Sklearn pipeline 中提取特征重要性

从我所做的简短研究来看,这在 scikit-learn 中似乎不可能,但我希望我是错的。

我还发现了一个名为 ELI5 的包(https://eli5.readthedocs.io/en/latest/overview.html),它应该可以解决 scikit-learn 的问题,但它并没有解决我的问题,因为名称为我输出的特征是 x1、x2 等,而不是实际的特征名称。

作为一种解决方法,我在管道之外完成了所有预处理,但很想知道如何在管道中进行预处理。

如果我可以提供任何有用的代码,请在评论中告诉我。

python pipeline python-3.x random-forest scikit-learn

5
推荐指数
1
解决办法
5670
查看次数