min_grid: Determine the minimum set of model fits

min_grid.model_specR Documentation

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 class 'model_spec'
min_grid(x, grid, ...)

fit_max_value(x, grid, ...)

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

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

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

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

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

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

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

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

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

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

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

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.

Value

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

Examples

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)

tune documentation built on May 29, 2024, 7:32 a.m.