<filename>Hasoc/create_folds.py
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/create_folds.ipynb (unless otherwise specified).

__all__ = ['df', 'df', 'y', 'kf', 'df', 'y']

# Cell
import os
import pandas as pd

from sklearn.model_selection import StratifiedKFold

# Cell
df = pd.read_csv(os.path.join('../data', 'en_task_a', 'hasoc_2020_en_train_new.csv'), sep='\t')

# Cell
df['kfold_task1'] = -1
df['kfold_task2'] = -1
df = df.sample(frac=1.,random_state=SEED).reset_index(drop=True)
y = df['task1'].values
kf = StratifiedKFold(n_splits=5)
for fold,(t_,v_) in enumerate(kf.split(X=df,y=y)):
    df.loc[v_,'kfold_task1'] = fold

df = df.sample(frac=1.,random_state=SEED).reset_index(drop=True)
y = df['task2'].values
for fold,(t_,v_) in enumerate(kf.split(X=df,y=y)):
    df.loc[v_,'kfold_task2'] = fold

# Cell
df.to_csv(os.path.join('..', 'data', 'fold_df.csv'), index=False)
<filename>Hasoc/create_folds.py
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/create_folds.ipynb (unless otherwise specified).

__all__ = ['df', 'df', 'y', 'kf', 'df', 'y']

# Cell
import os
import pandas as pd

from sklearn.model_selection import StratifiedKFold

# Cell
df = pd.read_csv(os.path.join('../data', 'en_task_a', 'hasoc_2020_en_train_new.csv'), sep='\t')

# Cell
df['kfold_task1'] = -1
df['kfold_task2'] = -1
df = df.sample(frac=1.,random_state=SEED).reset_index(drop=True)
y = df['task1'].values
kf = StratifiedKFold(n_splits=5)
for fold,(t_,v_) in enumerate(kf.split(X=df,y=y)):
    df.loc[v_,'kfold_task1'] = fold

df = df.sample(frac=1.,random_state=SEED).reset_index(drop=True)
y = df['task2'].values
for fold,(t_,v_) in enumerate(kf.split(X=df,y=y)):
    df.loc[v_,'kfold_task2'] = fold

# Cell
df.to_csv(os.path.join('..', 'data', 'fold_df.csv'), index=False)
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/create_folds.ipynb (unless otherwise specified). # Cell # Cell # Cell # Cell