Advertisement
jack06215

[sklearn][tensorflow][keras] Train-Validation-Test split

Sep 29th, 2020 (edited)
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. train_ratio = 0.75
  2. validation_ratio = 0.15
  3. test_ratio = 0.10
  4.  
  5. # train is now 75% of the entire datasets
  6. x_train, x_test, y_train, y_test = train_test_split(dataX, dataY, test_size=1 - train_ratio)
  7.  
  8. # test is now 10% of the initial datasets
  9. # validation is now 15% of the initial datasets
  10. x_val, x_test, y_val, y_test = train_test_split(x_test, y_test, test_size=test_ratio/(test_ratio + validation_ratio))
  11.  
  12. print(x_train, x_val, x_test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement