nullModel

0th

Percentile

Fit a simple, non-informative model

Fit a single mean or largest class model

Keywords
models
Usage
nullModel(x, ...)

## S3 method for class 'default': nullModel(x = NULL, y, ...)

## S3 method for class 'nullModel': predict(object, newdata = NULL, ...)

Arguments
x
An optional matrix or data frame of predictors. These values are not used in the model fit
y
A numeric vector (for regression) or factor (for classification) of outcomes
...
Optional arguments (not yet used)
object
An object of class nullModel
newdata
A matrix or data frame of predictors (only used to determine the number of predictions to return)
Details

nullModel emulates other model building functions, but returns the simplest model possible given a training set: a single mean for numeric outcomes and the most prevalent class for factor outcomes.

Value

  • The output of nullModel is a list of class nullModel with elements
  • callthe function call
  • valuethe mean of y or the most prevalent class
  • levelswhen y is a factor, a vector of levels. NULL otherwise
  • nthe number of elements in y
  • predict.nullModel returns a either a factor or numeric vector depending on the class of y. All predictions are always the same.

Aliases
  • nullModel
  • nullModel.default
  • predict.nullModel
Examples
outcome <- factor(
                  sample(letters[1:2], 
                         size = 100, 
                         prob = c(.1, .9), 
                         replace = TRUE))
useless <- nullModel(y = outcome)
useless
predict(useless, matrix(NA, nrow = 10))
Documentation reproduced from package caret, version 4.41, License: GPL-2

Community examples

Looks like there are no examples yet.