for gamma in [ ]for in [ ]for each combination of parameterstrain an svc svm svc(gamma=gammac=cperform cross-validation scores cross_val_score(svmx_trainvaly_trainvalcv= compute mean cross-validation accuracy score np mean(scoresif we got better scorestore the score and parameters if score best_scorebest_score score best_parameters {' ' 'gamma'gammarebuild model on the combined training and validation set svm svc(**best_parameterssvm fit(x_trainvaly_trainvalto evaluate the accuracy of the svm using particular setting of and gamma using five-fold cross-validationwe need to train models as you can imaginethe main downside of the use of cross-validation is the time it takes to train all these models the following visualization (figure - illustrates how the best parameter setting is selected in the preceding codein[ ]mglearn plots plot_cross_val_selection(figure - results of grid search with cross-validation for each parameter setting (only subset is shown)five accuracy values are computedone for each split in the cross-validation then the mean validation accuracy is computed for each parameter setting the parameters with the highest mean validation accuracy are chosenmarked by the circle model evaluation and improvement