Skip to content

Instantly share code, notes, and snippets.

@ashunigion
Created June 12, 2019 00:00
Show Gist options
  • Save ashunigion/c820c4a85439fd41bb0dd10c5b0a0772 to your computer and use it in GitHub Desktop.
Save ashunigion/c820c4a85439fd41bb0dd10c5b0a0772 to your computer and use it in GitHub Desktop.
Train, test, validation split
from sklearn.cross_validation import train_test_split
split_frac = 0.8
## split data into training, validation, and test data (features and labels, x and y)
train_x,test_x,train_y,test_y = train_test_split(features, encoded_labels, test_size = 0.2)
test_x,valid_x,test_y,valid_y = train_test_split(test_x,test_y, test_size = 0.5)
## print out the shapes of your resultant feature data
print((train_x.shape), (test_x.shape), (valid_x.shape))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment