In this code below, what is the meaning of the key kernel in the variable parameters?
from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVC
parameters = {'kernel': ('linear', 'rbf'), 'C': (1, 4, 8, 16, 32)}
svc = SVC()
clf = GridSearchCV(svc, parameters, cv=5)
clf.fit(train_x_vectors, train_y)
The purpose of grid search is to tune the hyperparameters of a given modelling algorithm. In particular, the
GridSearchCVobject needs to know which hyperparameters to vary, and what values to vary them over. That's what theparametersdictionary is for. All of the keys inparametersmust match hyperparameters for the particular algorithm.In this case,
kernelandCare hyperparameters for the support vector classifier (SVC) controlling the type of kernel to use, and the regularization parameter respectively. TheGridSearchCVmachinery is simply passing them on to the model.Check out the
SVCdocs and theGridSearchCVdocs