Find best hyperparameters using Grid Search in SVM (Support Vector Machine)
The hyperparameters optimization is a big part now a days in machine learning. In this post, we’ll use the grid search capability from the sklearn library to find the best parameters for SVM. We’ll be using wine dataset for this post( Link ). Here, I have divided the whole dataset as train and test data randomly. Grid search is the hyperparameter optimization technique. It is provided as GridSeachCV in sklearn. Let’s start with importing packages and loading the data. from sklearn.model_selection import train_test_split from sklearn import svm import numpy as np from sklearn.model_selection import StratifiedShuffleSplit from sklearn.model_selection import GridSearchCV # loading the data wine_train = np.loadtxt('wine.train',delimiter=',') wine_test = np.loadtxt('wine.test',delimiter=',') x = wine_train[:, 1:13] y = wine_train[:, 0] X_Test = wine_test[:, 1:13] x_train, x_test, y_train, y_test = train_test_split(x,y) Now, we will ...