13 tuners
By default, models fit on confidential data do not use additional hyperparameter tuning. This section describes how users can specify hyperparameter tuning schemes for their models using cross-validation.
13.1 tuner specifications
Each element passed to tuner is a named list with three required elements:
v: the number of cross-validation folds.grid: either adata.frameof tuning combinations or a positive integer of values to be created automatically. This value is passed totune::tune_grid()metric: alibrary(yardstick)metric function ormetric_setused to select an optimal hyperparameter.
Here’s an example:
When tuner objects are specified, the following steps occur:
- For each cross-validation fold (
v) and element of the hyperparameter grid (grid),tidysynthesisfits a model and calculates the metric (metric). - The metric results are averaged over cross-validation folds and the optimal model is selected.
- The optimal model is then used to generate samples.
As of version 0.1.0, hyperparameter optimization in tidysynthesis exclusively occurs at the confidential model fitting stage. Optimal hyperparameters will depend on confidential data, which may increase disclosure risks. When fitting models that may be sensitive to specific hyperparameter settings, consider determining hyperparameters based on public datasets.
13.2 Using tuners with model specifications
tidymodels provides the infrastructure for hyperparameter tuning through the library(tune) package. To do so, we first specify a model where specific hyperparameters are replaced with tune() objects.