Learn R Programming

tune (version 0.2.0)

min_grid.model_spec: Determine the minimum set of model fits

Description

min_grid() determines exactly what models should be fit in order to evaluate the entire set of tuning parameter combinations. This is for internal use only and the API may change in the near future.

Usage

# S3 method for model_spec
min_grid(x, grid, ...)

fit_max_value(x, grid, ...)

# S3 method for boost_tree min_grid(x, grid, ...)

# S3 method for linear_reg min_grid(x, grid, ...)

# S3 method for logistic_reg min_grid(x, grid, ...)

# S3 method for mars min_grid(x, grid, ...)

# S3 method for multinom_reg min_grid(x, grid, ...)

# S3 method for nearest_neighbor min_grid(x, grid, ...)

# S3 method for cubist_rules min_grid(x, grid, ...)

# S3 method for C5_rules min_grid(x, grid, ...)

# S3 method for rule_fit min_grid(x, grid, ...)

# S3 method for pls min_grid(x, grid, ...)

# S3 method for poisson_reg min_grid(x, grid, ...)

Value

A tibble with the minimum tuning parameters to fit and an additional list column with the parameter combinations used for prediction.

Arguments

x

A model specification.

grid

A tibble with tuning parameter combinations.

...

Not currently used.

Details

fit_max_value() can be used in other packages to implement a min_grid() method.

Examples

Run this code
library(dplyr)
library(dials)
library(parsnip)

## -----------------------------------------------------------------------------
## No ability to exploit submodels:

svm_spec <-
  svm_poly(cost = tune(), degree = tune()) %>%
  set_engine("kernlab") %>%
  set_mode("regression")

svm_grid <-
  svm_spec %>%
  extract_parameter_set_dials() %>%
  grid_regular(levels = 3)

min_grid(svm_spec, svm_grid)

## -----------------------------------------------------------------------------
## Can use submodels

xgb_spec <-
  boost_tree(trees = tune(), min_n = tune()) %>%
  set_engine("xgboost") %>%
  set_mode("regression")

xgb_grid <-
  xgb_spec %>%
  extract_parameter_set_dials() %>%
  grid_regular(levels = 3)

min_grid(xgb_spec, xgb_grid)

Run the code above in your browser using DataLab