judithabk6 / med_bench

BSD 3-Clause "New" or "Revised" License
8 stars 3 forks source link

Shorter KFold code chunks #31

Open sami6mz opened 1 year ago

sami6mz commented 1 year ago

In benchmark_mediation.py, there are 4 chunks of the following code :

kf = KFold(n_splits=crossfit)
        train_test_list = list()
        for train_index, test_index in kf.split(x):
            train_test_list.append([train_index, test_index])

Which I think we could replace by something more straightforward :

kf = KFold(n_splits=crossfit)
train_test_list = list(kf.split(x))

Or even :

train_test_list = list(KFold(n_splits=crossfit).split(x))

wdyt?

Note : First version of the code returns a list of lists, while the second returns a list of tuples.

sami6mz commented 1 year ago

Besides, could it be a good idea to shuffle the folds? kf = KFold(n_splits=crossfit,shuffle=True)

Anyway data dimulation is already randomized.

bthirion commented 1 year ago

No need then.

judithabk6 commented 7 months ago

@houssamzenati I think this is included in the refactor you plan to do, right?