如何在 scikit 的管道中添加 oversampling/undersampling 过程?

How to add oversampling/undersampling procedure in scikit's Pipeline?

我想添加过采样程序,如SMOTE oversampling, to scikit's Pipeline. But the transformers只支持fittransform方法,不提供增加样本和目标数量的方法。

实现此目的的一种可能方法是将管道断开为通过 SMOTE 采样连接的两个独立管道。

有没有更好的解决办法?

我们当前的 Pipeline 不支持更改步骤之间的样本数,因为 Transformer.transform 方法不 return y 参数,这也需要重新采样。这是当前设计的已知限制。它可能会在未来的版本中得到修复,但我们还没有开始着手解决这个问题。