-
-
Save makispl/6b3d7a181f91057b7d5c0c27a80b152e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
# read training data | |
df = pd.read_csv('../data/processed/train_proc_labeled.csv', | |
converters={'GAME_ID': lambda x: str(x)}) | |
# we create a new column called kfold and fill it with -1 | |
df['kfold'] = -1 | |
# randomize the rows of data | |
df = df.sample(frac=1).reset_index(drop=True) | |
# fetch labels | |
y = df.gm_cluster.values | |
# initiate the kfold class from model_Selection module | |
kf = model_selection.StratifiedKFold(n_splits=5) | |
# fill the new kfold column | |
for f, (t_, v_) in enumerate(kf.split(X=df, y=y)): | |
df.loc[v_, 'kfold'] = f | |
# save the new csv with kfold column | |
df.to_csv( | |
'../data/processed/train_proc_labeled_folds.csv', index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment