Skip to content

Instantly share code, notes, and snippets.

@Mehdi-Amine
Created June 16, 2020 23:46
Show Gist options
  • Save Mehdi-Amine/300cfd42eea60a99ab8655aedded25fb to your computer and use it in GitHub Desktop.
Save Mehdi-Amine/300cfd42eea60a99ab8655aedded25fb to your computer and use it in GitHub Desktop.
splitting dataset into train, valid and test sets
from sklearn.model_selection import train_test_split
data = np.copy(tib)
train_set, test_set = train_test_split(data, test_size=0.3, random_state=42)
train_set, valid_set = train_test_split(train_set, test_size=0.2, random_state=42)
# printing the shapes of the datasets
train_set.shape, valid_set.shape, test_set.shape
'''
Out:
((3360, 4), (840, 4), (1800, 4))
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment