DictVectorizer错误:Inverse_transform引发错误

时间:2018-07-14 08:30:48

标签: python machine-learning scikit-learn nlp dictvectorizer

我正在研究以下sklearn管道。

pipeline = Pipeline([

('PreProcess', TweetPreprocessor()),

# Use FeatureUnion to combine the features
('union', FeatureUnion(

        transformer_list =[
                            ('tweet_ngrams', Pipeline([
                                ('selector', ItemSelector(key='tweets')),
                                ('tfidf', TfidfVectorizer(ngram_range =(1, 2), analyzer='word')),
                                ])
                            ),

                            ('tweet_features', Pipeline(
                                [('selector', ItemSelector(key='tweets')),
                                ('stats', TextStats()),  # returns a list of dicts
                                ('vect', DictVectorizer()),  # list of dicts -> feature matrix
                                ]
                            )
        ),

    ],

)),

# Use a SVC classifier on the combined features
('svc', SVC(kernel='linear')),])

clf.coef_给了我

Output of clf.coef_

现在,当我运行以下代码时。它给了我索引超出范围的错误。我尝试重塑,但没有帮助。

vect.inverse_transform(clf.coef_)

Error message

我希望找回有助于分类的功能。预先感谢。

0 个答案:

没有答案