Hyperparameter tuning with grid search
No doubt you have noticed that we can provide various parameters to the model classes when we instantiate them. These model parameters are not derived from the data itself and are referred to as hyperparameters. Some examples of these are regularization terms, which we will discuss later in this chapter, and weights. Through the process of model tuning, we seek to optimize our model's performance by tuning these hyperparameters.
How can we know we are picking the best values to optimize our model's performance? One way is to use a technique called grid search to tune these hyperparameters. Grid search allows us to define a search space and test all combinations of hyperparameters in that space, keeping the ones that result in the best model. The scoring criterion we define will determine the best model.
Remember the elbow point method we discussed in Chapter 9, Getting Started with Machine Learning in Python, for finding a good...