So far, we have worked with some parametric models—those that learn some parameters from the data, for example, multiple linear regression, logistic regression, and multilayer perceptrons. However, in most models there are some parameters that are not directly learned from data. We need to choose their values, which are called hyperparameters. I have been choosing those hyperparameters for different models in the examples using the libraries' defaults or what I think might be good values based on my experience and best practices in the field of predictive analytics. However, if we want our model to perform better, we need to do some hyperparameter tuning—the activity of finding good values for the hyperparameters of our models.
In the first example of the section, we will use our diamond prices dataset:
- Let's do the necessary imports...