-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
mlr_learners_regr.lm.Rd
192 lines (172 loc) · 8 KB
/
mlr_learners_regr.lm.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/LearnerRegrLM.R
\name{mlr_learners_regr.lm}
\alias{mlr_learners_regr.lm}
\alias{LearnerRegrLM}
\title{Linear Model Regression Learner}
\description{
Ordinary linear regression.
Calls \code{\link[stats:lm]{stats::lm()}}.
}
\section{Dictionary}{
This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} \link{mlr_learners} or with the associated sugar function \code{\link[=lrn]{lrn()}}:
\if{html}{\out{<div class="sourceCode">}}\preformatted{mlr_learners$get("regr.lm")
lrn("regr.lm")
}\if{html}{\out{</div>}}
}
\section{Meta Information}{
\itemize{
\item Task type: \dQuote{regr}
\item Predict Types: \dQuote{response}, \dQuote{se}
\item Feature Types: \dQuote{logical}, \dQuote{integer}, \dQuote{numeric}, \dQuote{character}, \dQuote{factor}
\item Required Packages: \CRANpkg{mlr3}, \CRANpkg{mlr3learners}, 'stats'
}
}
\section{Parameters}{
\tabular{lllll}{
Id \tab Type \tab Default \tab Levels \tab Range \cr
df \tab numeric \tab Inf \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr
interval \tab character \tab - \tab none, confidence, prediction \tab - \cr
level \tab numeric \tab 0.95 \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr
model \tab logical \tab TRUE \tab TRUE, FALSE \tab - \cr
offset \tab logical \tab - \tab TRUE, FALSE \tab - \cr
pred.var \tab untyped \tab - \tab \tab - \cr
qr \tab logical \tab TRUE \tab TRUE, FALSE \tab - \cr
scale \tab numeric \tab NULL \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr
singular.ok \tab logical \tab TRUE \tab TRUE, FALSE \tab - \cr
x \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr
y \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr
rankdeficient \tab character \tab - \tab warnif, simple, non-estim, NA, NAwarn \tab - \cr
tol \tab numeric \tab 1e-07 \tab \tab \eqn{(-\infty, \infty)}{(-Inf, Inf)} \cr
verbose \tab logical \tab FALSE \tab TRUE, FALSE \tab - \cr
}
}
\section{Contrasts}{
To ensure reproducibility, this learner always uses the default contrasts:
\itemize{
\item \code{\link[=contr.treatment]{contr.treatment()}} for unordered factors, and
\item \code{\link[=contr.poly]{contr.poly()}} for ordered factors.
}
Setting the option \code{"contrasts"} does not have any effect.
Instead, set the respective hyperparameter or use \CRANpkg{mlr3pipelines} to create dummy features.
}
\examples{
if (requireNamespace("stats", quietly = TRUE)) {
# Define the Learner and set parameter values
learner = lrn("regr.lm")
print(learner)
# Define a Task
task = tsk("mtcars")
# Create train and test set
ids = partition(task)
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
# print the model
print(learner$model)
# importance method
if("importance" \%in\% learner$properties) print(learner$importance)
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
}
}
\seealso{
\itemize{
\item Chapter in the \href{https://mlr3book.mlr-org.com/}{mlr3book}:
\url{https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html#sec-learners}
\item Package \href{https://github.com/mlr-org/mlr3extralearners}{mlr3extralearners} for more learners.
\item \link[mlr3misc:Dictionary]{Dictionary} of \link[=Learner]{Learners}: \link{mlr_learners}
\item \code{as.data.table(mlr_learners)} for a table of available \link[=Learner]{Learners} in the running session (depending on the loaded packages).
\item \CRANpkg{mlr3pipelines} to combine learners with pre- and postprocessing steps.
\item Extension packages for additional task types:
\itemize{
\item \CRANpkg{mlr3proba} for probabilistic supervised regression and survival analysis.
\item \CRANpkg{mlr3cluster} for unsupervised clustering.
}
\item \CRANpkg{mlr3tuning} for tuning of hyperparameters, \CRANpkg{mlr3tuningspaces}
for established default tuning spaces.
}
Other Learner:
\code{\link{mlr_learners_classif.cv_glmnet}},
\code{\link{mlr_learners_classif.glmnet}},
\code{\link{mlr_learners_classif.kknn}},
\code{\link{mlr_learners_classif.lda}},
\code{\link{mlr_learners_classif.log_reg}},
\code{\link{mlr_learners_classif.multinom}},
\code{\link{mlr_learners_classif.naive_bayes}},
\code{\link{mlr_learners_classif.nnet}},
\code{\link{mlr_learners_classif.qda}},
\code{\link{mlr_learners_classif.ranger}},
\code{\link{mlr_learners_classif.svm}},
\code{\link{mlr_learners_classif.xgboost}},
\code{\link{mlr_learners_regr.cv_glmnet}},
\code{\link{mlr_learners_regr.glmnet}},
\code{\link{mlr_learners_regr.kknn}},
\code{\link{mlr_learners_regr.km}},
\code{\link{mlr_learners_regr.nnet}},
\code{\link{mlr_learners_regr.ranger}},
\code{\link{mlr_learners_regr.svm}},
\code{\link{mlr_learners_regr.xgboost}}
}
\concept{Learner}
\section{Super classes}{
\code{\link[mlr3:Learner]{mlr3::Learner}} -> \code{\link[mlr3:LearnerRegr]{mlr3::LearnerRegr}} -> \code{LearnerRegrLM}
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-LearnerRegrLM-new}{\code{LearnerRegrLM$new()}}
\item \href{#method-LearnerRegrLM-loglik}{\code{LearnerRegrLM$loglik()}}
\item \href{#method-LearnerRegrLM-clone}{\code{LearnerRegrLM$clone()}}
}
}
\if{html}{\out{
<details><summary>Inherited methods</summary>
<ul>
<li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="base_learner"><a href='../../mlr3/html/Learner.html#method-Learner-base_learner'><code>mlr3::Learner$base_learner()</code></a></span></li>
<li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="format"><a href='../../mlr3/html/Learner.html#method-Learner-format'><code>mlr3::Learner$format()</code></a></span></li>
<li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="help"><a href='../../mlr3/html/Learner.html#method-Learner-help'><code>mlr3::Learner$help()</code></a></span></li>
<li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="predict"><a href='../../mlr3/html/Learner.html#method-Learner-predict'><code>mlr3::Learner$predict()</code></a></span></li>
<li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="predict_newdata"><a href='../../mlr3/html/Learner.html#method-Learner-predict_newdata'><code>mlr3::Learner$predict_newdata()</code></a></span></li>
<li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="print"><a href='../../mlr3/html/Learner.html#method-Learner-print'><code>mlr3::Learner$print()</code></a></span></li>
<li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="reset"><a href='../../mlr3/html/Learner.html#method-Learner-reset'><code>mlr3::Learner$reset()</code></a></span></li>
<li><span class="pkg-link" data-pkg="mlr3" data-topic="Learner" data-id="train"><a href='../../mlr3/html/Learner.html#method-Learner-train'><code>mlr3::Learner$train()</code></a></span></li>
</ul>
</details>
}}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-LearnerRegrLM-new"></a>}}
\if{latex}{\out{\hypertarget{method-LearnerRegrLM-new}{}}}
\subsection{Method \code{new()}}{
Creates a new instance of this \link[R6:R6Class]{R6} class.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{LearnerRegrLM$new()}\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-LearnerRegrLM-loglik"></a>}}
\if{latex}{\out{\hypertarget{method-LearnerRegrLM-loglik}{}}}
\subsection{Method \code{loglik()}}{
Extract the log-likelihood (e.g., via \code{\link[stats:logLik]{stats::logLik()}} from the fitted model.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{LearnerRegrLM$loglik()}\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-LearnerRegrLM-clone"></a>}}
\if{latex}{\out{\hypertarget{method-LearnerRegrLM-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{LearnerRegrLM$clone(deep = FALSE)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{</div>}}
}
}
}