How to implement SMOTE in cross validation and GridSearchCV

后端 未结 2 706
独厮守ぢ
独厮守ぢ 2021-02-03 11:22

I\'m relatively new to Python. Can you help me improve my implementation of SMOTE to a proper pipeline? What I want is to apply the over and under sampling on the training set o

2条回答
  •  长情又很酷
    2021-02-03 11:46

    This looks like it would fit the bill http://contrib.scikit-learn.org/imbalanced-learn/stable/generated/imblearn.over_sampling.SMOTE.html

    You'll want to create your own transformer (http://scikit-learn.org/stable/modules/generated/sklearn.base.TransformerMixin.html) that upon calling fit returns a balanced data set (presumably the one gotten from StratifiedKFold), but upon calling predict, which is that is going to happen for the test data, calls into SMOTE.

提交回复
热议问题