Skip to content

Instantly share code, notes, and snippets.

@AyishaR
Created February 6, 2021 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AyishaR/52ea1b5c8c1104b4b7439ea1eb10fca4 to your computer and use it in GitHub Desktop.
Save AyishaR/52ea1b5c8c1104b4b7439ea1eb10fca4 to your computer and use it in GitHub Desktop.
# Splitting into train, val and test set -- 80-10-10 split
# First, an 80-20 split
train_df, val_test_df = train_test_split(df, test_size = 0.2, random_state = 113)
# Then split the 20% into half
val_df, test_df = train_test_split(val_test_df, test_size = 0.5, random_state = 113)
# Defining the input and output columns
ic = df.columns.tolist()
ic.remove('RainTomorrow')
oc = ['RainTomorrow']
# Split into X and y
ytrain = train_df[oc]
Xtrain = train_df.drop(columns = oc)
yval = val_df[oc]
Xval = val_df.drop(columns = oc)
ytest = test_df[oc]
Xtest = test_df.drop(columns = oc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment