split dataset into train, test and validation sets 1

split dataset into train, test and validation sets

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)
X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=0.25, random_state=1)

Here is what the above code is Doing:
1. We are splitting the data into training, validation and test sets.
2. We are using the train_test_split function from the sklearn.model_selection library.
3. We are splitting the data into 80% training, 10% validation and 10% test.
4. We are setting the random_state to 1. This is to ensure that we get the same split every time we run the code.

Similar Posts