1

I'd like to do something like this :

Skf = sklearn.model_selection.StratifiedKFold(n_splits = 5, shuffle = True) 
ALPHA,BETA  = Skf.split(data_X, data_Y)

and then :

for train_index, test_index in ALPHA,BETA

However, it isn't working, why and how to bypass that problem ?

My idea is that I want to use the same split a few times at different part of my code... I don't know how to "stock" the split.

Marine Galantin
  • 1,634
  • 1
  • 17
  • 28

1 Answers1

0

Yes, you can. You can specify the seed used by the random number generator, so that you obtain the same split over different runs. Just specify the random_state parameter!

SEED = 42
Skf = sklearn.model_selection.StratifiedKFold(n_splits=5,
                                              shuffle=True,
                                              random_state=SEED) 
Daniele Cappuccio
  • 1,952
  • 2
  • 16
  • 31