Coercion methods to BenchmarkAggr. For mlr3::BenchmarkResult this is a simple
wrapper around the BenchmarkAggr constructor called with mlr3::BenchmarkResult$aggregate().
Usage
as_benchmark_aggr(
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
#> <fctr> <fctr> <num> <num>
#> 1: A L1 0.32479066 0.25579946
#> 2: A L2 0.45048285 0.56770732
#> 3: A L3 0.76496334 0.31155450
#> 4: A L4 0.90876290 0.36487585
#> 5: A L5 0.16555703 0.32065847
#> 6: B L1 0.88281852 0.57593691
#> 7: B L2 0.29577488 0.79170309
#> 8: B L3 0.96893888 0.45660585
#> 9: B L4 0.48209023 0.81317970
#> 10: B L5 0.07904644 0.01575358
if (requireNamespaces(c("mlr3", "rpart"))) {
library(mlr3)
task = tsks(c("pima", "spam"))
learns = lrns(c("classif.featureless", "classif.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("classif.acc"))
}
#> <BenchmarkAggr> of 4 rows with 2 tasks, 2 learners and 1 measure
#> task_id learner_id acc
#> <fctr> <fctr> <num>
#> 1: pima featureless 0.6510417
#> 2: pima rpart 0.7539062
#> 3: spam featureless 0.6059566
#> 4: spam rpart 0.9030644