concept test dataset in category jupyter

This is an excerpt from Manning's book Machine Learning for Business: Using Amazon SageMaker and Jupyter.
In listing 2.8, you create two datasets: a dataset with 70% of the data for training and a dataset with 30% of the data for validation and testing. Then you split the validation and test data into two separate datasets: a validation dataset and a test dataset. The validation dataset will contain 20% of the total rows, which equals 66.7% of the validation and test dataset. The test dataset will contain 10% of the total rows, which equals 33.3% of the validation and test dataset. To run the code, insert your cursor in the cell and press
.
Create training, validation, and test datasets.
The stratify parameter is particularly useful for datasets where the target variable you are predicting is relatively rare. The parameter works by shuffling the deck as it’s building the machine learning model and making sure that the train, validate, and test datasets contain similar ratios of target variables. This ensures that the model does not get thrown off course by an unrepresentative selection of customers in any of the datasets.
Listing 3.6. Creating the training, validation, and test datasets
y = encoded_data['churned'] #1 train_df, test_and_val_data, _, _ = train_test_split( encoded_data, y, test_size=0.3, stratify=y, random_state=0) #2 y = test_and_val_data['churned'] val_df, test_df, _, _ = train_test_split( testing_data, y, test_size=0.333, stratify=y, random_state=0) #3 print(train_df.shape, val_df.shape, test_df.shape) print() print('Train') print(train_df['churned'].value_counts()) #4 print() print('Validate') print(val_df['churned'].value_counts()) print() print('Test') print(test_df['churned'].value_counts())
.