Scikit learn 转换器应该实现fit()和transform()

Scikit learn 转换器应该实现fit()和transform(),scikit-learn,Scikit Learn,我不明白为什么sklearn的这段管道代码不起作用……cna其他人知道我为什么会出错: TypeError: All intermediate steps should be transformers and implement fit and transform. pipeline = Pipeline([ ('features', FeatureUnion([ ('plots', Pipeline([ ('selector', movies_

我不明白为什么sklearn的这段管道代码不起作用……cna其他人知道我为什么会出错:

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()方法。啊。谢谢

你把管道放在管道里面吗?你能添加一些数据和完整的代码吗?谢谢!数据将来自train_test_split()的4个变量,下面是我调用pipeline.fit(X_train,y_train)的代码块。但奇怪的是,它不起作用,因为它说fit()和transform()不适用于我的估计器,它们显然是这样。错误在
电影\u encoded
中。不能简单地将数据列放入
管道中。您只需要在
fit()
中传递数据。检查此示例,了解如何从数据中选择单个列: