rasbt / mlxtend

A library of extension and helper modules for Python's data analysis and machine learning libraries.
https://rasbt.github.io/mlxtend/
Other
4.86k stars 857 forks source link

Stratified cross-validation in both StackingCVClassifier and GridSearchCV? #770

Closed antranttu closed 3 years ago

antranttu commented 3 years ago

Hello,

I'm working on a super imbalanced dataset, and I'm doing resampling during Stacked CV Classification combined with GridSearch to search for the best hyperparameters. I was wondering if I need to pass my StratifiedKFold object as arguments in both StackingCVClassifier and GridSearchCV, or just one of the two will suffice?

Thank you!

rasbt commented 3 years ago

Good question. StackingCVClassifier should use stratified k-fold by default when you set cv to some integer value (or leave the default).

As far as I know, GridSearchCV performs stratified k-fold as well, so you don't need to pass StratifiedKFold manually.

Hope that helps!