4

我想同时应用交叉验证和过采样。我从这段代码中得到以下错误:

from sklearn.pipeline import Pipeline, make_pipeline
imba_pipeline = make_pipeline(SMOTE(random_state=42), 
                              LogisticRegression(C=3.4))
cross_val_score(imba_pipeline, X_train_tf, y_train, scoring='f1-weighted', cv=kf)

所有中间步骤应该是转换器并实现拟合和转换,或者是字符串 'passthrough' 'SMOTE(k_neighbors=5, kind='deprecated', m_neighbors='deprecated', n_jobs=1, out_step='deprecated', random_state=42 , ratio=None, sampling_strategy='auto', svm_estimator='deprecated')' (type ) 没有

PS。我使用imblearn.over_sampling.RandomOverSampler而不是SMOTE得到了同样的错误。

4

1 回答 1

15

您应该从而不是从导入:make_pipeline从sklearn 需要转换器来实现和方法,但不实现。imblearn.pipelinesklearn.pipelinemake_pipelinefittransformSMOTEtransform

于 2019-11-12T21:02:33.157 回答