text_plain_output_1.png
from iterstrat.ml_stratifiers import MultilabelStratifiedKFold

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import sys

dftr = pd.read_csv('/kaggle/input/feedback-prize-english-language-learning//train.csv')
dftr['src'] = 'train'
dfte = pd.read_csv('/kaggle/input/feedback-prize-english-language-learning//test.csv')
dfte['src'] = 'test'
df = pd.concat([dftr, dfte], ignore_index=True)

target_cols = ['cohesion', 'syntax', 'vocabulary', 'phraseology', 'grammar', 'conventions']

import sys
sys.path.append('../input/iterativestratification')
from iterstrat.ml_stratifiers import MultilabelStratifiedKFold
FOLDS = 5
skf = MultilabelStratifiedKFold(n_splits=FOLDS, shuffle=True, random_state=2022)
for i, (train_index, val_index) in enumerate(skf.split(dftr, dftr[target_cols])):
    dftr.loc[val_index, 'FOLD'] = i
dftr.FOLD.value_counts()