变形金刚应该实现fit()和transform()

时间:2018-11-18 02:36:34

标签: scikit-learn

我不明白为什么sklearn的这段管道代码无法正常工作...其他人都知道为什么我得到了错误:

TypeError: All intermediate steps should be transformers and implement fit and transform.

pipeline = Pipeline([
    ('features', FeatureUnion([
        ('plots', Pipeline([
            ('selector', movies_encoded['Plot']),
            ('count_vector', CountVectorizer(tokenizer=nltk.word_tokenize)),
            ('tfidf', TfidfTransformer())
        ])),
        ('genres', Pipeline([
            ('selector', movies_encoded['Rating_Encoded']),
            ('labeler', LabelEncoder())
        ]))
    ])),
    ('neural_network', MLPClassifier(alpha=0.01, hidden_layer_sizes=(100, 100, ), early_stopping=False, verbose=True))
])

所有估计量都具有transform()或fit_transform()方法。啊谢谢!

0 个答案:

没有答案