gpt4 book ai didi

python - SMOTE 函数在 make_pipeline 中不起作用

转载 作者:行者123 更新时间:2023-12-03 23:12:10 30 4
gpt4 key购买 nike

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

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)

ll intermediate steps should be transformers and implement fit and transform or be the string '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 ) doesn't



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

最佳答案

您应该从 make_pipeline 而不是从 imblearn.pipeline 导入 o​​jit_code :来自 sklearn 的 sklearn.pipeline 需要转换器来实现 make_pipelinefit 方法,但 transform 没有实现 SMOTE

关于python - SMOTE 函数在 make_pipeline 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58825053/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com