train test validation sklearn

Solutions on MaxInterview for train test validation sklearn by the best coders in the world

showing results for - "train test validation sklearn"
Alexander
01 May 2019
1# credit to the user of StackExchange in the source link
2# set stratify=y in the function arguments for stratified selection
3# random_state has been fixed for reproducibility
4
5from sklearn.model_selection import train_test_split
6
7X_train, X_test, y_train, y_test 
8	= train_test_split(X, y, test_size=0.2, random_state=1) 
9
10# 0.25 x 0.8 = 0.2
11X_train, X_val, y_train, y_val 
12    = train_test_split(X_train, y_train, test_size=0.25, random_state=1)