相关疑难解决方法(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万
查看次数

从FeatureUnion + Pipeline中获取要素名称

我正在使用FeatureUnion来加入从事件标题和描述中找到的功能:

union = FeatureUnion(
    transformer_list=[
    # Pipeline for pulling features from the event's title
        ('title', Pipeline([
            ('selector', TextSelector(key='title')),
            ('count', CountVectorizer(stop_words='english')),
        ])),

        # Pipeline for standard bag-of-words model for description
        ('description', Pipeline([
            ('selector', TextSelector(key='description_snippet')),
            ('count', TfidfVectorizer(stop_words='english')),
        ])),
    ],

    transformer_weights ={
            'title': 1.0,
            'description': 0.2
    },
)
Run Code Online (Sandbox Code Playgroud)

但是,调用union.get_feature_names()给我一个错误:"变换器标题(类型管道)不提供get_feature_names." 我想看看我的不同矢量化器生成的一些功能.我该怎么做呢?

nlp feature-extraction python-3.x scikit-learn

16
推荐指数
2
解决办法
5879
查看次数