repeats (default: 10) times repeated folds-fold (default: 10) cross-validation.

The iteration counter translates to repeats blocks of folds cross-validations, i.e., the first folds iterations belong to a single cross-validation.

ResamplingRepeatedCV

Format

R6::R6Class() inheriting from Resampling.

Fields

  • id :: character(1)
    Stores the identifier of the learner.

  • task_type :: character(1)
    Stores the type of class this learner can operate on, e.g. "classif" or "regr". A complete list of task types is stored in mlr_reflections$task_types.

  • param_set :: paradox::ParamSet
    Description of available hyperparameters and hyperparameter settings.

  • predict_types :: character()
    Stores the possible predict types the learner is capable of. A complete list of candidate predict types, grouped by task type, is stored in mlr_reflections$learner_predict_types.

  • predict_type :: character(1)
    Stores the currently selected predict type. Must be an element of l$predict_types.

  • feature_types :: character()
    Stores the feature types the learner can handle, e.g. "logical", "numeric", or "factor". A complete list of candidate feature types, grouped by task type, is stored in mlr_reflections$task_feature_types.

  • properties :: character()
    Stores a set of properties/capabilities the learner has. A complete list of candidate properties, grouped by task type, is stored in mlr_reflections$learner_properties.

  • packages :: character()
    Stores the names of required packages.

  • fallback :: (Learner | NULL)
    Optionally stores a second Learner which is activated as fallback if this first Learner fails during train or predict. This mechanism is disabled unless you explicitly assign a learner to this slot. Additionally, you need to catch raised exceptions via encapsulation, see mlr_control().

  • hash :: character(1)
    Hash (unique identifier) for this object.

Methods

  • params(tag)
    character(1) -> named list()
    Returns a list of hyperparameter settings from param_set where the corresponding parameters in param_set are tagged with tag. I.e., l$params("train") returns all settings of hyperparameters used in the training step.

  • train(task)
    Task -> self
    Train the learner on the complete Task. The resulting model is stored in l$model.

  • predict(task)
    Task -> Prediction
    Uses l$model (fitted during train()) to return a Prediction object.

Examples

# Create a task with 10 observations task = mlr_tasks$get("iris") task$filter(1:10) # Instantiate Resampling rrcv = mlr_resamplings$get("repeated_cv") rrcv$param_set$values = list(repeats = 2, folds = 3) rrcv$instantiate(task) rrcv$iters
#> [1] 6
rrcv$folds(1:6)
#> [1] 1 2 1 2 1 2
rrcv$repeats(1:6)
#> [1] 1 1 1 2 2 2
# Individual sets: rrcv$train_set(1)
#> [1] 1 2 10 3 5 8
rrcv$test_set(1)
#> [1] 4 6 7 9
intersect(rrcv$train_set(1), rrcv$test_set(1))
#> integer(0)
# Internal storage: rrcv$instance # table
#> row_id rep fold #> 1: 1 1 2 #> 2: 2 1 2 #> 3: 3 1 3 #> 4: 4 1 1 #> 5: 5 1 3 #> 6: 6 1 1 #> 7: 7 1 1 #> 8: 8 1 3 #> 9: 9 1 1 #> 10: 10 1 2 #> 11: 1 2 1 #> 12: 2 2 2 #> 13: 3 2 3 #> 14: 4 2 3 #> 15: 5 2 2 #> 16: 6 2 1 #> 17: 7 2 3 #> 18: 8 2 2 #> 19: 9 2 1 #> 20: 10 2 1