A description of a resampling algorithm contains all necessary information to create a ResampleInstance, when given the size of the data set.
makeResampleDesc(
method,
predict = "test",
...,
stratify = FALSE,
stratify.cols = NULL,
fixed = FALSE,
blocking.cv = FALSE
)
(character(1)
)
“CV” for cross-validation, “LOO” for leave-one-out, “RepCV” for
repeated cross-validation, “Bootstrap” for out-of-bag bootstrap, “Subsample” for
subsampling, “Holdout” for holdout, “GrowingWindowCV” for growing window
cross-validation, “FixedWindowCV” for fixed window cross validation.
(character(1)
)
What to predict during resampling: “train”, “test” or “both” sets.
Default is “test”.
(any) Further parameters for strategies.
integer(1)
)Number of iterations, for “CV”, “Subsample” and “Bootstrap”.
numeric(1)
)Proportion of training cases for “Holdout” and “Subsample” between 0 and 1. Default is 2 / 3.
integer(1)
)Repeats for “RepCV”. Here iters = folds * reps
.
Default is 10.
integer(1)
)Folds in the repeated CV for RepCV
.
Here iters = folds * reps
. Default is 10.
numeric(1)
)Number of observations in the forecast test set for “GrowingWindowCV”
and “FixedWindowCV”. When horizon > 1
this will be treated as the number of
observations to forecast, else it will be a fraction of the initial window. IE,
for 100 observations, initial window of .5, and horizon of .2, the test set will have
10 observations. Default is 1.
numeric(1)
)Fraction of observations to start with
in the training set for “GrowingWindowCV” and “FixedWindowCV”.
When initial.window > 1
this will be treated as the number of
observations in the initial window, else it will be treated as the fraction
of observations to have in the initial window. Default is 0.5.
numeric(1)
)How many resamples to skip to thin the total amount
for “GrowingWindowCV” and “FixedWindowCV”. This is passed through as the “by” argument
in seq()
. When skip > 1
this will be treated as the increment of the sequence of resampling indices,
else it will be a fraction of the total training indices. IE for 100 training sets and a value of .2, the increment
of the resampling indices will be 20. Default is “horizon” which gives mutually exclusive chunks
of test indices.
(logical(1)
)
Should stratification be done for the target variable?
For classification tasks, this means that the resampling strategy is applied to all classes
individually and the resulting index sets are joined to make sure that the proportion of
observations in each training set is as in the original data set. Useful for imbalanced class sizes.
For survival tasks stratification is done on the events, resulting in training sets with comparable
censoring rates.
(character)
Stratify on specific columns referenced by name. All columns have to be factor or integer.
Note that you have to ensure yourself that stratification is possible, i.e.
that each strata contains enough observations.
This argument and stratify
are mutually exclusive.
(logical(1)
)
Whether indices supplied via argument 'blocking' in the task should be used as
fully pre-defined indices. Default is FALSE
which means
they will be used following the 'blocking' approach.
fixed
only works with ResampleDesc CV
and the supplied indices must match
the number of observations. When fixed = TRUE
, the iters
argument will be ignored
and is interally set to the number of supplied factor levels in blocking
.
(logical(1)
)
Should 'blocking' be used in CV
? Default to FALSE
.
This is different to fixed = TRUE
and cannot be combined. Please check the mlr online tutorial
for more details.
(ResampleDesc).
For common resampling strategies you can save some typing by using the following description objects:
holdout a.k.a. test sample estimation (two-thirds training set, one-third testing set)
2-fold cross-validation
3-fold cross-validation
5-fold cross-validation
10-fold cross-validation
Some notes on some special strategies:
Use “RepCV”. Then you have to set the aggregation function for your preferred performance measure to “testgroup.mean” via setAggregation.
Use “Bootstrap” for bootstrap and set predict to “both”. Then you have to set the aggregation function for your preferred performance measure to “b632” via setAggregation.
Use “Bootstrap” for bootstrap and set predict to “both”. Then you have to set the aggregation function for your preferred performance measure to “b632plus” via setAggregation.
Object slots:
character(1)
)Name of resampling strategy.
integer(1)
)Number of iterations. Note that this is always the complete number of generated train/test sets, so for a 10-times repeated 5fold cross-validation it would be 50.
character(1)
)See argument.
logical(1)
)See argument.
See arguments.
Other resample:
ResamplePrediction
,
ResampleResult
,
addRRMeasure()
,
getRRPredictionList()
,
getRRPredictions()
,
getRRTaskDescription()
,
getRRTaskDesc()
,
makeResampleInstance()
,
resample()
# NOT RUN {
# Bootstraping
makeResampleDesc("Bootstrap", iters = 10)
makeResampleDesc("Bootstrap", iters = 10, predict = "both")
# Subsampling
makeResampleDesc("Subsample", iters = 10, split = 3 / 4)
makeResampleDesc("Subsample", iters = 10)
# Holdout a.k.a. test sample estimation
makeResampleDesc("Holdout")
# }
Run the code above in your browser using DataLab