Learn R Programming

mlr (version 1.1-18)

resample: Fit models according to a resampling strategy.

Description

Given a resampling strategy, which defines sets of training and test indices, fits the selected learner using the training sets and performs predictions for the training/test sets. (This depends on what you selected in the resampling strategy, see parameter predict in makeResampleDesc.) Then performance measures are calculated and aggregated. You are able to return all fitted models (parameter models) or extract specific parts of the models (parameter extract) as returning all of them completely might be memory intensive.

Usage

resample(learner, task, resampling, measures, weights,
    models = FALSE, extract = function(model) { },
    show.info = TRUE)

Arguments

Value

List of:measures.test [data.frame]Rows correspond to test sets in resampling iterations, columns to performance measures.measures.train [data.frame]Rows correspond to training sets in resampling iterations, columns to performance measures.aggr [named numeric]Vector of aggregated performance values. Names are coded like this ..pred [ResamplePrediction]Container for all predictions during resampling.models [list of WrappedModel]List of fitted models or NULL.extract [list]List of extracted parts from fitted models or NULL.

Details

For construction of the resampling strategies use the factory methods makeResampleDesc and makeResampleInstance.

See Also

makeResampleDesc, makeResampleInstance

Examples

Run this code
task <- makeClassifTask(data = iris, target = "Species")
rdesc <- makeResampleDesc("Bootstrap", iters = 10)
rin <- makeResampleInstance(rdesc, task = task)
r1 <- resample(makeLearner("classif.qda"), task, rin)
print(r1$measures.test)
print(r1$aggr)
r2 <- resample(makeLearner("classif.rpart"), task, rin)
print(r2$measures.test)
print(r2$aggr)

Run the code above in your browser using DataLab