This is the result container object returned by benchmark().

Note that all stored objects are accessed by reference. Do not modify any object without cloning it first.

Format

R6::R6Class object.

Construction

bmr = BenchmarkResult$new(data)

Fields

Methods

  • aggregated(objects = TRUE, ids = TRUE, params = FALSE)
    (logical(1), logical(1), logical(1)) -> data.table::data.table()
    Returns a result table where experiments are aggregated per ResampleResult. Arguments control the number of additional columns:

    • objects :: logical(1)
      Return objects as columns in the result data.table().

    • ids :: logical(1)
      Return object ids as columns in the result data.table().

    • params :: logical(1)
      Return learner hyperparameter values as list column params in the result data.table().

  • combine(bmr)
    BenchmarkResult -> self
    Fuses a second BenchmarkResult into itself.

  • get_best(id)
    (character(1)) -> ResampleResult
    Returns the ResampleResult with best performance according to Measure with the provided id.

S3 Methods

Examples

set.seed(123) design = expand_grid( tasks = "iris", learners = c("classif.featureless", "classif.rpart"), resamplings = "cv3" ) print(design)
#> task learner resampling #> 1: <TaskClassif> <LearnerClassifFeatureless> <ResamplingCV> #> 2: <TaskClassif> <LearnerClassifRpart> <ResamplingCV>
bmr = benchmark(design) print(bmr)
#> <BenchmarkResult> of 6 experiments in 2 resamplings: #> task learner resampling classif.ce #> iris classif.rpart cv3 0.05333333 #> iris classif.featureless cv3 0.72000000
bmr$tasks
#> task_hash task_id task #> 1: 696859dff593fab2 iris <TaskClassif>
bmr$learners
#> learner_hash learner_id learner #> 1: 712b957a1b72f4f7 classif.featureless <LearnerClassifFeatureless> #> 2: b5074c22cc2d7e3d classif.rpart <LearnerClassifRpart>
bmr$measures
#> measure_hash measure_id measure #> 1: 9c21eb12ed97a674 classif.ce <MeasureClassifCE>
# aggregated results bmr$aggregated()
#> hash resample_result task learner #> 1: 2612f45e95ed289c <ResampleResult> <TaskClassif> <LearnerClassifFeatureless> #> 2: be912c26317e145b <ResampleResult> <TaskClassif> <LearnerClassifRpart> #> task_id learner_id resampling_id classif.ce #> 1: iris classif.featureless cv3 0.72000000 #> 2: iris classif.rpart cv3 0.05333333
# aggregated results with hyperparameters as separate columns mlr3misc::unnest(bmr$aggregated(params = TRUE), "params")
#> hash resample_result task learner #> 1: 2612f45e95ed289c <ResampleResult> <TaskClassif> <LearnerClassifFeatureless> #> 2: be912c26317e145b <ResampleResult> <TaskClassif> <LearnerClassifRpart> #> task_id learner_id resampling_id classif.ce method xval #> 1: iris classif.featureless cv3 0.72000000 mode NA #> 2: iris classif.rpart cv3 0.05333333 <NA> 0
# extract resample result for classif.rpart rr = bmr$aggregated()[learner_id == "classif.rpart", resample_result][[1]] print(rr)
#> <ResampleResult> of learner 'iris' on task 'classif.rpart' with 3 iterations #> Measure Min. 1st Qu. Median Mean 3rd Qu. Max. Sd #> classif.ce 0.04 0.05 0.06 0.05333 0.06 0.06 0.01155
# access the confusion matrix of the first resampling iteration rr$experiment(1)$prediction$confusion
#> truth #> response setosa versicolor virginica #> setosa 18 0 0 #> versicolor 0 19 2 #> virginica 0 1 10