How it works...
In the previous recipe, Building a nonlinear classifier using SVMs, we repeatedly modified the kernel of the SVM algorithm to obtain an improvement in the classification of data. On the basis of the hyperparameter definition given at the beginning of the recipe, it is clear that the kernel represents a hyperparameter. In this recipe, we randomly set the value for this hyperparameter and checked the results to find out which value determines the best performance. However, a random selection of algorithm parameters may be inadequate.
Furthermore, it is difficult to compare the performance of different algorithms by setting the parameters randomly, because an algorithm can perform better than another with a different set of parameters. And if the parameters are changed, the algorithm may have worse results than the other algorithms.
As a result, the random selection of parameter values is not the best approach we can take to find the best performance for our model. On the contrary, it would be advisable to develop an algorithm that automatically finds the best parameters for a particular model. There are several methods for searching for hyperparameters, such as the following: grid search, randomized search, and Bayesian optimization.