min_cols: Execution-time data dimension checks

View source: R/arguments.R

min_colsR Documentation

Execution-time data dimension checks

Description

For some tuning parameters, the range of values depend on the data dimensions (e.g. mtry). Some packages will fail if the parameter values are outside of these ranges. Since the model might receive resampled versions of the data, these ranges can't be set prior to the point where the model is fit. These functions check the possible range of the data and adjust them if needed (with a warning).

Usage

min_cols(num_cols, source)

min_rows(num_rows, source, offset = 0)

Arguments

num_cols, num_rows

The parameter value requested by the user.

source

A data frame for the data to be used in the fit. If the source is named "data", it is assumed that one column of the data corresponds to an outcome (and is subtracted off).

offset

A number subtracted off of the number of rows available in the data.

Value

An integer (and perhaps a warning).

Examples


nearest_neighbor(neighbors= 100) %>%
  set_engine("kknn") %>%
  set_mode("regression") %>%
  translate()

library(ranger)
rand_forest(mtry = 2, min_n = 100, trees = 3) %>%
  set_engine("ranger") %>%
  set_mode("regression") %>%
  fit(mpg ~ ., data = mtcars)


parsnip documentation built on June 24, 2024, 5:14 p.m.