Chapter 1: Introduction to Machine Learning with Keras
Activity 1: Adding Regularization to the Model
Solution:
- Load the feature data from Exercise 1 and the target data from the second activity. The feature data from the second activity can also be used:
import pandas as pd
feats = pd.read_csv(‘data/bank_data_feats_e3.csv’, index_col=0)
target = pd.read_csv(‘data/bank_data_target_e2.csv’, index_col=0)
- We will again create a test and train dataset. We will train the data using the training dataset. This time, however, we will use part of the training dataset for validation in order to choose the most appropriate hyperparameter.
We will again use test_size = 0.2, which means that 20% of the data will be reserved for testing. The size of our validation set will be determined by how many validation folds we have. If we do 10-fold cross-validation, this equates to reserving 10% of the training dataset to validate our model on. Each fold will use a different 10...