-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathnullmodel.Rd
72 lines (62 loc) · 2.51 KB
/
nullmodel.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nullmodel.R
\name{nullmodel}
\alias{nullmodel}
\alias{nullmodel.default}
\alias{predict.nullmodel}
\alias{print.nullmodel}
\title{Fit a simple, non-informative model}
\usage{
nullmodel(x, ...)
\method{nullmodel}{default}(x = NULL, y, ...)
\method{print}{nullmodel}(x, ...)
\method{predict}{nullmodel}(object, new_data = NULL, type = NULL, ...)
}
\arguments{
\item{x}{An optional matrix or data frame of predictors. These values are
not used in the model fit}
\item{\dots}{Optional arguments (not yet used)}
\item{y}{A numeric vector (for regression) or factor (for classification) of
outcomes}
\item{object}{An object of class \code{nullmodel}}
\item{new_data}{A matrix or data frame of predictors (only used to determine
the number of predictions to return)}
\item{type}{Either "raw" (for regression), "class" or "prob" (for
classification)}
}
\value{
The output of \code{nullmodel()} is a list of class \code{nullmodel}
with elements \item{call }{the function call} \item{value }{the mean of
\code{y} or the most prevalent class} \item{levels }{when \code{y} is a
factor, a vector of levels. \code{NULL} otherwise} \item{pct }{when \code{y}
is a factor, a data frame with a column for each class (\code{NULL}
otherwise). The column for the most prevalent class has the proportion of
the training samples with that class (the other columns are zero). } \item{n
}{the number of elements in \code{y}}
\code{predict.nullmodel()} returns either a factor or numeric vector
depending on the class of \code{y}. All predictions are always the same.
}
\description{
Fit a single mean or largest class model. \code{nullmodel()} is the underlying
computational function for the \code{null_model()} specification.
}
\details{
\code{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.
}
\examples{
\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
outcome <- factor(sample(letters[1:2],
size = 100,
prob = c(.1, .9),
replace = TRUE))
useless <- nullmodel(y = outcome)
useless
predict(useless, matrix(NA, nrow = 5))
\dontshow{\}) # examplesIf}
}
\keyword{internal}
\keyword{models}