imbLearn.smote没有“transform”方法。Docs:
https://imbalanced-learn.readthedocs.io/en/stable/generated/imblearn.over_sampling.SMOTE.html
但除了管道中的最后一个步骤之外,所有步骤都应该有它以及“fit”。
要与sklearn pipeline一起使用smote,您应该在“transform”方法中实现一个自定义转换器调用smote.fit_sample()。
另一个更简单的选择是使用ibmlearn管道:
from imblearn.over_sampling import SMOTE
from imblearn.pipeline import Pipeline as imbPipeline
# This doesn't work with sklearn.pipeline.Pipeline because
# SMOTE doesn't have a .tranform() method.
# (It has .fit_sample() or .sample().)
pipe = imbPipeline([
...
('oversample', SMOTE(random_state=5)),
('clf', LinearSVC(class_weight='balanced'))
])