Let's see how to find optimal hyperparameters:
- The full code is given in the perform_grid_search.py file that's already provided to you. We start importing the libraries:
from sklearn import svmfrom sklearn import model_selectionfrom sklearn.model_selection import GridSearchCVfrom sklearn.metrics import classification_reportimport pandas as pdimport utilities
- Then, we load the data:
input_file = 'data_multivar.txt'X, y = utilities.load_data(input_file)
- We split the data into a train and test dataset:
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.25, random_state=5)
- Now, we will use cross-validation here, which we covered in the previous recipes. Once you load the data and split ...