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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/resample.R, R/resample_convenience.R
\name{resample}
\alias{resample}
\alias{crossval}
\alias{repcv}
\alias{holdout}
\alias{subsample}
\alias{bootstrapOOB}
\alias{bootstrapB632}
\alias{bootstrapB632plus}
\alias{growingcv}
\alias{fixedcv}
\title{Fit models according to a resampling strategy.}
\usage{
resample(
learner,
task,
resampling,
measures,
weights = NULL,
models = FALSE,
extract,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
crossval(
learner,
task,
iters = 10L,
stratify = FALSE,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
repcv(
learner,
task,
folds = 10L,
reps = 10L,
stratify = FALSE,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
holdout(
learner,
task,
split = 2/3,
stratify = FALSE,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
subsample(
learner,
task,
iters = 30,
split = 2/3,
stratify = FALSE,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
bootstrapOOB(
learner,
task,
iters = 30,
stratify = FALSE,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
bootstrapB632(
learner,
task,
iters = 30,
stratify = FALSE,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
bootstrapB632plus(
learner,
task,
iters = 30,
stratify = FALSE,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
growingcv(
learner,
task,
horizon = 1,
initial.window = 0.5,
skip = 0,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
fixedcv(
learner,
task,
horizon = 1L,
initial.window = 0.5,
skip = 0,
measures,
models = FALSE,
keep.pred = TRUE,
...,
show.info = getMlrOption("show.info")
)
}
\arguments{
\item{learner}{(\link{Learner} | \code{character(1)})\cr
The learner.
If you pass a string the learner will be created via \link{makeLearner}.}
\item{task}{(\link{Task})\cr
The task.}
\item{resampling}{(\link{ResampleDesc} or \link{ResampleInstance})\cr
Resampling strategy.
If a description is passed, it is instantiated automatically.}
\item{measures}{(\link{Measure} | list of \link{Measure})\cr
Performance measure(s) to evaluate.
Default is the default measure for the task, see here \link{getDefaultMeasure}.}
\item{weights}{(\link{numeric})\cr
Optional, non-negative case weight vector to be used during fitting.
If given, must be of same length as observations in task and in corresponding order.
Overwrites weights specified in the \code{task}.
By default \code{NULL} which means no weights are used unless specified in the task.}
\item{models}{(\code{logical(1)})\cr
Should all fitted models be returned?
Default is \code{FALSE}.}
\item{extract}{(\code{function})\cr
Function used to extract information from a fitted model during resampling.
Is applied to every \link{WrappedModel} resulting from calls to \link{train}
during resampling.
Default is to extract nothing.}
\item{keep.pred}{(\code{logical(1)})\cr
Keep the prediction data in the \code{pred} slot of the result object.
If you do many experiments (on larger data sets) these objects might unnecessarily increase
object size / mem usage, if you do not really need them.
The default is set to \code{TRUE}.}
\item{...}{(any)\cr
Further hyperparameters passed to \code{learner}.}
\item{show.info}{(\code{logical(1)})\cr
Print verbose output on console?
Default is set via \link{configureMlr}.}
\item{iters}{(\code{integer(1)})\cr
See \link{ResampleDesc}.}
\item{stratify}{(\code{logical(1)})\cr
See \link{ResampleDesc}.}
\item{folds}{(\code{integer(1)})\cr
See \link{ResampleDesc}.}
\item{reps}{(\code{integer(1)})\cr
See \link{ResampleDesc}.}
\item{split}{(\code{numeric(1)})\cr
See \link{ResampleDesc}.}
\item{horizon}{(\code{numeric(1)})\cr
See \link{ResampleDesc}.}
\item{initial.window}{(\code{numeric(1)})\cr
See \link{ResampleDesc}.}
\item{skip}{(\code{integer(1)})\cr
See \link{ResampleDesc}.}
}
\value{
(\link{ResampleResult}).
}
\description{
The function \code{resample} fits a model specified by \link{Learner} on a \link{Task}
and calculates predictions and performance \link{measures} for all training
and all test sets specified by a either a resampling description (\link{ResampleDesc})
or resampling instance (\link{ResampleInstance}).
You are able to return all fitted models (parameter \code{models}) or extract specific parts
of the models (parameter \code{extract}) as returning all of them completely
might be memory intensive.
The remaining functions on this page are convenience wrappers for the various
existing resampling strategies. Note that if you need to work with precomputed training and
test splits (i.e., resampling instances), you have to stick with \code{resample}.
}
\note{
If you would like to include results from the training data set, make
sure to appropriately adjust the resampling strategy and the aggregation for
the measure. See example code below.
}
\examples{
task = makeClassifTask(data = iris, target = "Species")
rdesc = makeResampleDesc("CV", iters = 2)
r = resample(makeLearner("classif.qda"), task, rdesc)
print(r$aggr)
print(r$measures.test)
print(r$pred)
# include the training set performance as well
rdesc = makeResampleDesc("CV", iters = 2, predict = "both")
r = resample(makeLearner("classif.qda"), task, rdesc,
measures = list(mmce, setAggregation(mmce, train.mean)))
print(r$aggr)
}
\seealso{
Other resample:
\code{\link{ResamplePrediction}},
\code{\link{ResampleResult}},
\code{\link{addRRMeasure}()},
\code{\link{getRRPredictionList}()},
\code{\link{getRRPredictions}()},
\code{\link{getRRTaskDesc}()},
\code{\link{getRRTaskDescription}()},
\code{\link{makeResampleDesc}()},
\code{\link{makeResampleInstance}()}
}
\concept{resample}
|