# nullModel

From caret v5.07-001
by Max Kuhn

##### 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, type = NULL, ...)

##### 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. When class probabilities are requested, the percentage of the training set samples with the most prevalent class is returned.

##### Value

- The output of
`nullModel`

is a list of class`nullModel`

with elements call the function call value the mean of `y`

or the most prevalent classlevels when `y`

is a factor, a vector of levels.`NULL`

otherwisepct when `y`

is a factor, a data frame with a column for each class (`NULL`

otherwise). The column for the most prevalent class has the proportion of the training samples with that class (the other columns are zero).n the 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.

##### 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 5.07-001, License: GPL-2*

### Community examples

Looks like there are no examples yet.