Chapter 12. Model Tuning and the Dangers of Overfitting

In order to use a model for prediction, the parameters for that model must be estimated. Some of these parameters can be estimated directly from the training data, but other parameters, called tuning parameters or hyperparameters, must be specified ahead of time and can’t be directly found from training data. These are unknown structural values or other kinds of values that have significant impact on the model but cannot be directly estimated from the data. This chapter will provide examples of tuning parameters and show how we use the tidymodels functions to create and handle tuning parameters. We’ll also demonstrate how poor choices of these values lead to overfitting and introduce several tactics for finding optimal tuning parameters values. Chapters 13 and 14 go into more detail on specific optimization methods for tuning.

Model Parameters

In ordinary linear regression, there are two parameters β 0 and β 1 of the model:

y i = β 0 + β 1 x i + ϵ i

When we have the outcome ( y ) and predictor ( x ) data, we can estimate the two parameters β 0 and β 1 :

β ^ 1 = ∑ i (y i -y ¯)(x i -x ¯) ∑ i (x i -x ¯) 2

and

β ^ 0 = y ¯ - β ^ 1 x ¯ .

We can directly estimate these values from the data for this example model because they are analytically tractable; if we have the data, then we can estimate these model parameters.

Note

There are many situations where a model has parameters ...

Get Tidy Modeling with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.