Skip to contents

This function is deprecated, use as_benchmark_aggr() instead.

Coercion methods to BenchmarkAggr. For mlr3::BenchmarkResult this is a simple wrapper around the BenchmarkAggr constructor called with mlr3::BenchmarkResult$aggregate().

Usage

as.BenchmarkAggr(
  obj,
  task_id = "task_id",
  learner_id = "learner_id",
  independent = TRUE,
  strip_prefix = TRUE,
  ...
)

Arguments

obj

(mlr3::BenchmarkResult|matrix(1))
Passed to BenchmarkAggr$new().

task_id, learner_id, independent, strip_prefix

See BenchmarkAggr$initialize().

...

ANY
Passed to mlr3::BenchmarkResult$aggregate().

Examples

df = data.frame(tasks = factor(rep(c("A", "B"), each = 5),
                               levels = c("A", "B")),
                learners = factor(paste0("L", 1:5)),
                RMSE = runif(10), MAE = runif(10))

as_benchmark_aggr(df, task_id = "tasks", learner_id = "learners")
#> <BenchmarkAggr> of 10 rows with 2 tasks, 5 learners and 2 measures
#>     tasks learners        RMSE       MAE
#>  1:     A       L1 0.559789459 0.4570633
#>  2:     A       L2 0.002290237 0.1227826
#>  3:     A       L3 0.776127588 0.8278673
#>  4:     A       L4 0.669480762 0.2226462
#>  5:     A       L5 0.177777942 0.2227702
#>  6:     B       L1 0.165226459 0.9500858
#>  7:     B       L2 0.869296228 0.3566457
#>  8:     B       L3 0.444505573 0.8204197
#>  9:     B       L4 0.994601162 0.8391115
#> 10:     B       L5 0.872711837 0.6716113


if (requireNamespaces(c("mlr3", "rpart"))) {
  library(mlr3)
  task = tsks(c("boston_housing", "mtcars"))
  learns = lrns(c("regr.featureless", "regr.rpart"))
  bm = benchmark(benchmark_grid(task, learns, rsmp("cv", folds = 2)))

  # default measure
  as_benchmark_aggr(bm)

  # change measure
  as_benchmark_aggr(bm, measures = msr("regr.rmse"))
}
#> <BenchmarkAggr> of 4 rows with 2 tasks, 2 learners and 1 measure
#>           task_id  learner_id     rmse
#> 1: boston_housing featureless 9.237456
#> 2: boston_housing       rpart 1.711798
#> 3:         mtcars featureless 5.922222
#> 4:         mtcars       rpart 5.922222