Stratified KFold CV for Regression



I want to create a Stratified KFold with a flag variable which values are 0 and 1. Then I want to use with this custom fold instance. If I create any KFold instance and use it as a fold in parameters it works without any problem but when I want to use Stratifed KFold I got IndexError: list index out of range error. When using KFold folds = KFold() is enough. For Stratified one need to define split argument with y. So I’m trying with folds = StratifiedKFold().split(X,y) and get index error. I can use lightgbm with that way without any problem. Is there any proper way to use it? Thanks in advance.


Hello silverstone -

Were you able to find a solution to this issue?


Hi @FuzzyCoder, I have not found any solution yet, still waiting for an answer or suggestion.


Can you explicitly pass the list of indicies for each fold? See the entry for at