Skip to content

Fit a single mean, set of quantiles, or largest class model. null_model() is the user-facing function that relies on the underlying computational function, nullmodel().

Usage

null_model(mode = "classification", engine = "parsnip")

Arguments

mode

A single character string for the type of model. The only possible values for this model are "regression", "quantile regression", and "classification".

engine

A single character string specifying what computational engine to use for fitting. Possible engines are listed below. The default for this model is "parsnip".

Details

null_model() defines a simple, non-informative model. It doesn't have any main arguments. This function can fit classification, regression, and quantile regression models.

null_model() emulates other model building functions, but returns the simplest model possible given a training set: a single mean or set of quantiles for numeric outcomes and the most prevalent class for factor outcomes. When class probabilities are requested, the percentage of the training set samples with the most prevalent class is returned.

Engine Details

Engines may have pre-set default arguments when executing the model fit call. For this type of model, the template of the fit calls are below:

parsnip

null_model() |>
  set_engine("parsnip") |>
  set_mode("regression") |>
  translate()

## Null Model Specification (regression)
##
## Computational engine: parsnip
##
## Model fit template:
## parsnip::nullmodel(x = missing_arg(), y = missing_arg())

null_model() |>
  set_engine("parsnip") |>
  set_mode("quantile regression", quantile_levels = c(0.25, 0.5, 0.75)) |>
  translate()

## Null Model Specification (quantile regression)
##
## Computational engine: parsnip
##
## Model fit template:
## parsnip::nullmodel(x = missing_arg(), y = missing_arg(), quantile_levels = quantile_levels)

## Quantile levels: 0.25, 0.5, and 0.75.

null_model() |>
  set_engine("parsnip") |>
  set_mode("classification") |>
  translate()

## Null Model Specification (classification)
##
## Computational engine: parsnip
##
## Model fit template:
## parsnip::nullmodel(x = missing_arg(), y = missing_arg())

Prediction types

parsnip:::get_from_env("null_model_predict") |>
  dplyr::filter(engine == "parsnip") |>
  dplyr::select(mode, type)

## # A tibble: 6 x 2
##   mode                type
##   <chr>               <chr>
## 1 quantile regression quantile
## 2 regression          numeric
## 3 regression          raw
## 4 classification      class
## 5 classification      prob
## 6 classification      raw

See also

Examples

null_model(mode = "regression")
#> Null Model Specification (regression)
#> 
#> Computational engine: parsnip 
#>