carry over to new data because we used the test data to adjust the parameterswe can no longer use it to assess how good the model is this is the same reason we needed to split the data into training and test sets in the first placewe need an independent dataset to evaluateone that was not used to create the model one way to resolve this problem is to split the data againso we have three setsthe training set to build the modelthe validation (or developmentset to select the parameters of the modeland the test set to evaluate the performance of the selected parameters figure - shows what this looks likein[ ]mglearn plots plot_threefold_split(figure - threefold split of data into training setvalidation setand test set after selecting the best parameters using the validation setwe can rebuild model using the parameter settings we foundbut now training on both the training data and the validation data this waywe can use as much data as possible to build our model this leads to the following implementationin[ ]from sklearn svm import svc split data into train+validation set and test set x_trainvalx_testy_trainvaly_test train_test_splitiris datairis targetrandom_state= split train+validation set into training and validation sets x_trainx_validy_trainy_valid train_test_splitx_trainvaly_trainvalrandom_state= print("size of training set{size of validation set{size of test set:{}\nformat(x_train shape[ ]x_valid shape[ ]x_test shape[ ])best_score for gamma in [ ]for in [ ]for each combination of parameterstrain an svc svm svc(gamma=gammac=csvm fit(x_trainy_trainevaluate the svc on the test set score svm score(x_validy_validif we got better scorestore the score and parameters if score best_scorebest_score score best_parameters {' ' 'gamma'gamma model evaluation and improvement