mlr-org / mlr3

mlr3: Machine Learning in R - next generation
https://mlr3.mlr-org.com
GNU Lesser General Public License v3.0
945 stars 85 forks source link

Error when extracting AIC from BenchmarkResults #801

Closed vera-karlbauer closed 2 months ago

vera-karlbauer commented 2 years ago

I get an error message when trying to extract the AIC from the benchmark results for a classification task. The same issue occurs when trying to get the BIC, but other measures like accuracy or CE work fine. Find my reprex below: (Note about the code: I have my learners wrapped as GraphLearners because I'm using pipelines with several preprocessing steps in my actual work.)

  library(mlr3)
  library(mlr3learners)
  library(mlr3pipelines)

# define task
task = tsk("sonar")

## Pipeline 1: featureless
# define learner
learner_featureless = po("learner", lrn("classif.featureless"))
# define graph
graph_featureless = learner_featureless
# convert graph to GraphLearner
learner_graph_featureless = as_learner(graph_featureless)

## Pipeline 2: LASSO
# define learner
learner_lasso = po("learner", lrn("classif.cv_glmnet", alpha = 1, id = "lasso"))
# define graph
graph_lasso = learner_lasso
# convert graph to GraphLearner
learner_graph_lasso = as_learner(graph_lasso)

## Pipeline 3: Ridge
# define learner
learner_ridge = po("learner", lrn("classif.cv_glmnet", alpha = 0, id = "ridge"))
# define graph
graph_ridge = learner_ridge
# convert graph to GraphLearner
learner_graph_ridge = as_learner(graph_ridge)

# define resampling
resampling = rsmp("repeated_cv")

# define benchmark object
design = benchmark_grid(
  tasks = task,
  learners = c(learner_graph_featureless, learner_graph_lasso, learner_graph_ridge),
  resamplings = resampling
)

# instantiate learners and resampling
bmr <- benchmark(design, store_models = TRUE)
#> INFO  [13:57:32.272] [mlr3] Running benchmark with 300 resampling iterations 
#> INFO  [13:57:32.354] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 34/100) 
#> INFO  [13:57:34.013] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 43/100) 
#> INFO  [13:57:35.843] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 72/100) 
#> INFO  [13:57:35.883] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 92/100) 
#> INFO  [13:57:36.245] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 50/100) 
#> INFO  [13:57:36.606] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 28/100) 
#> INFO  [13:57:36.647] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 23/100) 
#> INFO  [13:57:38.010] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 31/100) 
#> INFO  [13:57:40.657] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 15/100) 
#> INFO  [13:57:40.691] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 56/100) 
#> INFO  [13:57:40.724] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 37/100) 
#> INFO  [13:57:41.028] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 56/100) 
#> INFO  [13:57:42.899] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 87/100) 
#> INFO  [13:57:43.210] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 100/100) 
#> INFO  [13:57:43.266] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 81/100) 
#> INFO  [13:57:43.596] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 65/100) 
#> INFO  [13:57:43.647] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 69/100) 
#> INFO  [13:57:43.695] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 22/100) 
#> INFO  [13:57:43.746] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 48/100) 
#> INFO  [13:57:44.115] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 58/100) 
#> INFO  [13:57:45.854] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 22/100) 
#> INFO  [13:57:46.193] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 52/100) 
#> INFO  [13:57:46.242] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 77/100) 
#> INFO  [13:57:46.579] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 74/100) 
#> INFO  [13:57:46.610] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 94/100) 
#> INFO  [13:57:46.645] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 46/100) 
#> INFO  [13:57:48.856] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 24/100) 
#> INFO  [13:57:49.185] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 9/100) 
#> INFO  [13:57:51.593] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 48/100) 
#> INFO  [13:57:51.623] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 100/100) 
#> INFO  [13:57:52.090] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 40/100) 
#> INFO  [13:57:54.396] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 36/100) 
#> INFO  [13:57:56.265] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 1/100) 
#> INFO  [13:57:57.542] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 73/100) 
#> INFO  [13:57:59.603] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 58/100) 
#> INFO  [13:57:59.634] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 50/100) 
#> INFO  [13:58:00.891] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 89/100) 
#> INFO  [13:58:00.921] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 25/100) 
#> INFO  [13:58:00.964] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 57/100) 
#> INFO  [13:58:01.266] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 70/100) 
#> INFO  [13:58:01.296] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 76/100) 
#> INFO  [13:58:03.949] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 60/100) 
#> INFO  [13:58:04.250] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 19/100) 
#> INFO  [13:58:04.546] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 30/100) 
#> INFO  [13:58:07.124] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 27/100) 
#> INFO  [13:58:09.564] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 17/100) 
#> INFO  [13:58:12.148] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 43/100) 
#> INFO  [13:58:12.180] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 61/100) 
#> INFO  [13:58:14.894] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 78/100) 
#> INFO  [13:58:16.873] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 97/100) 
#> INFO  [13:58:16.912] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 26/100) 
#> INFO  [13:58:19.121] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 69/100) 
#> INFO  [13:58:21.500] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 88/100) 
#> INFO  [13:58:21.543] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 93/100) 
#> INFO  [13:58:21.850] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 45/100) 
#> INFO  [13:58:21.895] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 97/100) 
#> INFO  [13:58:22.200] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 99/100) 
#> INFO  [13:58:24.993] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 6/100) 
#> INFO  [13:58:27.672] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 91/100) 
#> INFO  [13:58:27.720] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 91/100) 
#> INFO  [13:58:28.053] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 54/100) 
#> INFO  [13:58:28.094] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 30/100) 
#> INFO  [13:58:28.431] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 22/100) 
#> INFO  [13:58:31.597] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 41/100) 
#> INFO  [13:58:33.457] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 12/100) 
#> INFO  [13:58:33.502] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 68/100) 
#> INFO  [13:58:33.861] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 45/100) 
#> INFO  [13:58:36.268] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 68/100) 
#> INFO  [13:58:36.308] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 84/100) 
#> INFO  [13:58:36.347] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 74/100) 
#> INFO  [13:58:38.904] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 87/100) 
#> INFO  [13:58:41.088] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 2/100) 
#> INFO  [13:58:41.121] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 5/100) 
#> INFO  [13:58:43.126] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 76/100) 
#> INFO  [13:58:43.467] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 91/100) 
#> INFO  [13:58:46.609] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 80/100) 
#> INFO  [13:58:46.947] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 24/100) 
#> INFO  [13:58:46.978] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 77/100) 
#> INFO  [13:58:47.008] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 70/100) 
#> INFO  [13:58:47.357] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 29/100) 
#> INFO  [13:58:49.006] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 75/100) 
#> INFO  [13:58:51.007] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 40/100) 
#> INFO  [13:58:51.038] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 99/100) 
#> INFO  [13:58:51.370] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 66/100) 
#> INFO  [13:58:51.409] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 84/100) 
#> INFO  [13:58:51.733] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 13/100) 
#> INFO  [13:58:52.063] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 15/100) 
#> INFO  [13:58:52.386] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 43/100) 
#> INFO  [13:58:52.799] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 97/100) 
#> INFO  [13:58:56.503] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 21/100) 
#> INFO  [13:59:00.102] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 36/100) 
#> INFO  [13:59:00.470] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 20/100) 
#> INFO  [13:59:00.841] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 42/100) 
#> INFO  [13:59:03.928] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 14/100) 
#> INFO  [13:59:04.280] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 85/100) 
#> INFO  [13:59:04.330] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 55/100) 
#> INFO  [13:59:04.637] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 37/100) 
#> INFO  [13:59:06.668] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 88/100) 
#> INFO  [13:59:09.570] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 92/100) 
#> INFO  [13:59:11.402] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 62/100) 
#> INFO  [13:59:11.446] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 89/100) 
#> INFO  [13:59:13.618] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 50/100) 
#> INFO  [13:59:13.663] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 40/100) 
#> INFO  [13:59:13.970] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 70/100) 
#> INFO  [13:59:16.974] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 23/100) 
#> INFO  [13:59:17.299] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 42/100) 
#> INFO  [13:59:17.592] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 86/100) 
#> INFO  [13:59:17.623] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 100/100) 
#> INFO  [13:59:19.505] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 68/100) 
#> INFO  [13:59:21.653] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 3/100) 
#> INFO  [13:59:24.291] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 90/100) 
#> INFO  [13:59:25.967] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 57/100) 
#> INFO  [13:59:26.000] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 55/100) 
#> INFO  [13:59:26.031] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 19/100) 
#> INFO  [13:59:28.068] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 2/100) 
#> INFO  [13:59:28.375] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 38/100) 
#> INFO  [13:59:28.649] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 7/100) 
#> INFO  [13:59:28.939] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 73/100) 
#> INFO  [13:59:28.986] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 25/100) 
#> INFO  [13:59:31.043] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 1/100) 
#> INFO  [13:59:31.074] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 15/100) 
#> INFO  [13:59:33.312] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 33/100) 
#> INFO  [13:59:33.342] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 44/100) 
#> INFO  [13:59:36.303] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 63/100) 
#> INFO  [13:59:36.610] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 69/100) 
#> INFO  [13:59:36.908] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 47/100) 
#> INFO  [13:59:39.302] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 53/100) 
#> INFO  [13:59:40.950] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 32/100) 
#> INFO  [13:59:41.243] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 16/100) 
#> INFO  [13:59:41.288] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 45/100) 
#> INFO  [13:59:41.578] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 83/100) 
#> INFO  [13:59:41.633] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 94/100) 
#> INFO  [13:59:41.940] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 60/100) 
#> INFO  [13:59:41.988] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 85/100) 
#> INFO  [13:59:43.457] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 74/100) 
#> INFO  [13:59:43.749] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 39/100) 
#> INFO  [13:59:44.070] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 20/100) 
#> INFO  [13:59:44.103] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 49/100) 
#> INFO  [13:59:45.901] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 52/100) 
#> INFO  [13:59:46.175] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 6/100) 
#> INFO  [13:59:46.487] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 48/100) 
#> INFO  [13:59:49.928] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 64/100) 
#> INFO  [13:59:50.209] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 5/100) 
#> INFO  [13:59:50.253] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 90/100) 
#> INFO  [13:59:50.587] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 82/100) 
#> INFO  [13:59:52.209] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 80/100) 
#> INFO  [13:59:52.252] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 93/100) 
#> INFO  [13:59:52.300] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 65/100) 
#> INFO  [13:59:52.598] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 95/100) 
#> INFO  [13:59:52.629] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 18/100) 
#> INFO  [13:59:52.660] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 86/100) 
#> INFO  [13:59:55.065] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 33/100) 
#> INFO  [13:59:56.589] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 95/100) 
#> INFO  [13:59:57.941] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 82/100) 
#> INFO  [13:59:58.243] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 87/100) 
#> INFO  [13:59:58.276] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 12/100) 
#> INFO  [13:59:58.574] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 66/100) 
#> INFO  [13:59:59.893] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 51/100) 
#> INFO  [14:00:00.199] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 1/100) 
#> INFO  [14:00:00.499] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 98/100) 
#> INFO  [14:00:00.542] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 33/100) 
#> INFO  [14:00:00.860] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 29/100) 
#> INFO  [14:00:01.166] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 32/100) 
#> INFO  [14:00:03.989] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 26/100) 
#> INFO  [14:00:04.305] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 47/100) 
#> INFO  [14:00:04.339] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 63/100) 
#> INFO  [14:00:06.511] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 18/100) 
#> INFO  [14:00:06.840] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 84/100) 
#> INFO  [14:00:10.081] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 53/100) 
#> INFO  [14:00:10.387] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 17/100) 
#> INFO  [14:00:10.434] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 75/100) 
#> INFO  [14:00:10.468] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 76/100) 
#> INFO  [14:00:10.499] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 20/100) 
#> INFO  [14:00:13.077] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 35/100) 
#> INFO  [14:00:13.110] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 19/100) 
#> INFO  [14:00:13.140] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 57/100) 
#> INFO  [14:00:15.726] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 72/100) 
#> INFO  [14:00:16.147] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 38/100) 
#> INFO  [14:00:17.825] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 42/100) 
#> INFO  [14:00:17.871] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 93/100) 
#> INFO  [14:00:19.955] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 17/100) 
#> INFO  [14:00:20.257] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 72/100) 
#> INFO  [14:00:21.757] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 25/100) 
#> INFO  [14:00:22.041] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 21/100) 
#> INFO  [14:00:22.350] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 46/100) 
#> INFO  [14:00:22.638] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 14/100) 
#> INFO  [14:00:24.339] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 83/100) 
#> INFO  [14:00:24.629] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 35/100) 
#> INFO  [14:00:26.382] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 49/100) 
#> INFO  [14:00:26.413] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 96/100) 
#> INFO  [14:00:27.982] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 96/100) 
#> INFO  [14:00:28.299] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 9/100) 
#> INFO  [14:00:28.677] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 95/100) 
#> INFO  [14:00:29.047] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 98/100) 
#> INFO  [14:00:29.458] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 64/100) 
#> INFO  [14:00:29.522] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 14/100) 
#> INFO  [14:00:29.600] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 61/100) 
#> INFO  [14:00:30.056] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 11/100) 
#> INFO  [14:00:30.469] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 83/100) 
#> INFO  [14:00:32.361] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 18/100) 
#> INFO  [14:00:36.594] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 59/100) 
#> INFO  [14:00:36.953] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 44/100) 
#> INFO  [14:00:37.009] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 92/100) 
#> INFO  [14:00:37.060] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 65/100) 
#> INFO  [14:00:39.024] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 62/100) 
#> INFO  [14:00:39.357] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 13/100) 
#> INFO  [14:00:41.035] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 27/100) 
#> INFO  [14:00:41.077] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 82/100) 
#> INFO  [14:00:41.116] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 16/100) 
#> INFO  [14:00:44.004] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 79/100) 
#> INFO  [14:00:44.337] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 89/100) 
#> INFO  [14:00:44.680] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 38/100) 
#> INFO  [14:00:44.722] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 86/100) 
#> INFO  [14:00:45.087] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 79/100) 
#> INFO  [14:00:45.128] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 44/100) 
#> INFO  [14:00:45.489] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 77/100) 
#> INFO  [14:00:47.750] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 63/100) 
#> INFO  [14:00:47.805] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 39/100) 
#> INFO  [14:00:50.406] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 5/100) 
#> INFO  [14:00:50.751] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 28/100) 
#> INFO  [14:00:53.034] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 29/100) 
#> INFO  [14:00:53.089] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 31/100) 
#> INFO  [14:00:53.468] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 3/100) 
#> INFO  [14:00:53.518] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 61/100) 
#> INFO  [14:00:53.554] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 56/100) 
#> INFO  [14:00:53.842] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 51/100) 
#> INFO  [14:00:57.549] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 30/100) 
#> INFO  [14:00:57.582] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 4/100) 
#> INFO  [14:00:57.880] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 2/100) 
#> INFO  [14:00:59.687] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 24/100) 
#> INFO  [14:01:02.089] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 47/100) 
#> INFO  [14:01:02.424] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 55/100) 
#> INFO  [14:01:05.245] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 79/100) 
#> INFO  [14:01:07.715] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 37/100) 
#> INFO  [14:01:07.747] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 88/100) 
#> INFO  [14:01:08.070] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 11/100) 
#> INFO  [14:01:09.700] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 67/100) 
#> INFO  [14:01:10.007] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 59/100) 
#> INFO  [14:01:10.042] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 4/100) 
#> INFO  [14:01:11.573] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 96/100) 
#> INFO  [14:01:11.617] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 60/100) 
#> INFO  [14:01:13.184] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 8/100) 
#> INFO  [14:01:16.578] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 62/100) 
#> INFO  [14:01:18.048] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 11/100) 
#> INFO  [14:01:18.086] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 58/100) 
#> INFO  [14:01:18.408] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 64/100) 
#> INFO  [14:01:19.665] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 31/100) 
#> INFO  [14:01:19.702] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 10/100) 
#> INFO  [14:01:19.734] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 34/100) 
#> INFO  [14:01:19.768] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 81/100) 
#> INFO  [14:01:19.800] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 49/100) 
#> INFO  [14:01:20.120] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 80/100) 
#> INFO  [14:01:21.972] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 3/100) 
#> INFO  [14:01:22.262] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 35/100) 
#> INFO  [14:01:22.573] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 71/100) 
#> INFO  [14:01:22.870] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 99/100) 
#> INFO  [14:01:22.922] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 75/100) 
#> INFO  [14:01:23.211] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 10/100) 
#> INFO  [14:01:25.041] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 23/100) 
#> INFO  [14:01:25.101] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 81/100) 
#> INFO  [14:01:28.488] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 34/100) 
#> INFO  [14:01:30.406] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 71/100) 
#> INFO  [14:01:32.371] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 78/100) 
#> INFO  [14:01:32.408] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 41/100) 
#> INFO  [14:01:32.689] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 13/100) 
#> INFO  [14:01:32.725] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 39/100) 
#> INFO  [14:01:32.770] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 21/100) 
#> INFO  [14:01:32.803] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 51/100) 
#> INFO  [14:01:32.863] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 6/100) 
#> INFO  [14:01:32.910] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 67/100) 
#> INFO  [14:01:35.223] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 98/100) 
#> INFO  [14:01:36.841] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 52/100) 
#> INFO  [14:01:38.434] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 16/100) 
#> INFO  [14:01:38.717] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 4/100) 
#> INFO  [14:01:38.750] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 78/100) 
#> INFO  [14:01:39.072] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 27/100) 
#> INFO  [14:01:39.363] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 53/100) 
#> INFO  [14:01:39.409] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 8/100) 
#> INFO  [14:01:39.444] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 85/100) 
#> INFO  [14:01:39.737] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 54/100) 
#> INFO  [14:01:40.056] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 54/100) 
#> INFO  [14:01:42.536] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 28/100) 
#> INFO  [14:01:42.839] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 26/100) 
#> INFO  [14:01:42.873] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 32/100) 
#> INFO  [14:01:42.923] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 66/100) 
#> INFO  [14:01:43.248] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 8/100) 
#> INFO  [14:01:43.557] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 94/100) 
#> INFO  [14:01:46.164] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 12/100) 
#> INFO  [14:01:47.813] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 7/100) 
#> INFO  [14:01:47.860] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 7/100) 
#> INFO  [14:01:50.294] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 90/100) 
#> INFO  [14:01:50.333] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 67/100) 
#> INFO  [14:01:50.365] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 10/100) 
#> INFO  [14:01:50.654] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 9/100) 
#> INFO  [14:01:50.695] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 41/100) 
#> INFO  [14:01:50.728] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 73/100) 
#> INFO  [14:01:51.041] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 36/100) 
#> INFO  [14:01:51.086] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 71/100) 
#> INFO  [14:01:51.137] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 46/100) 
#> INFO  [14:01:51.170] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 59/100) 
#> INFO  [14:01:53.242] [mlr3] Finished benchmark
print(bmr)
#> <BenchmarkResult> of 300 rows with 3 resampling runs
#>  nr task_id          learner_id resampling_id iters warnings errors
#>   1   sonar classif.featureless   repeated_cv   100        0      0
#>   2   sonar               lasso   repeated_cv   100        0      0
#>   3   sonar               ridge   repeated_cv   100        0      0

# get classification error
bmr$aggregate(measures = msr("classif.ce"))
#>    nr      resample_result task_id          learner_id resampling_id iters
#> 1:  1 <ResampleResult[22]>   sonar classif.featureless   repeated_cv   100
#> 2:  2 <ResampleResult[22]>   sonar               lasso   repeated_cv   100
#> 3:  3 <ResampleResult[22]>   sonar               ridge   repeated_cv   100
#>    classif.ce
#> 1:  0.4662857
#> 2:  0.2514762
#> 3:  0.2187857

# get aic
bmr$aggregate(measures = msr("aic"))
#> Error in learner$loglik(): attempt to apply non-function

Created on 2022-04-10 by the reprex package (v2.0.1)

mllg commented 2 years ago

This should be solved by https://github.com/mlr-org/mlr3pipelines/issues/603, waiting for the PR to be merged.

pat-s commented 2 years ago

@mllg This sounds somewhat important but I haven't found any linked PR - only the issue. Has there ever been a PR or did you mean to write "issue"?

jemus42 commented 2 months ago

This appears to be fixed in the sense that the code does not error anymore:

library(mlr3)
library(mlr3learners)
library(mlr3pipelines)

# define task
task = tsk("sonar")

## Pipeline 1: featureless
# define learner
learner_featureless = po("learner", lrn("classif.featureless"))
# define graph
graph_featureless = learner_featureless
# convert graph to GraphLearner
learner_graph_featureless = as_learner(graph_featureless)

## Pipeline 2: LASSO
# define learner
learner_lasso = po("learner", lrn("classif.cv_glmnet", alpha = 1, id = "lasso"))
# define graph
graph_lasso = learner_lasso
# convert graph to GraphLearner
learner_graph_lasso = as_learner(graph_lasso)

## Pipeline 3: Ridge
# define learner
learner_ridge = po("learner", lrn("classif.cv_glmnet", alpha = 0, id = "ridge"))
# define graph
graph_ridge = learner_ridge
# convert graph to GraphLearner
learner_graph_ridge = as_learner(graph_ridge)

# define resampling
resampling = rsmp("cv", folds = 3)

# define benchmark object
design = benchmark_grid(
  tasks = task,
  learners = c(learner_graph_featureless, learner_graph_lasso, learner_graph_ridge),
  resamplings = resampling
)

# instantiate learners and resampling
bmr <- benchmark(design, store_models = TRUE)
#> INFO  [12:00:51.352] [mlr3] Running benchmark with 9 resampling iterations
#> INFO  [12:00:51.398] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 1/3)
#> INFO  [12:00:51.427] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 2/3)
#> INFO  [12:00:51.448] [mlr3] Applying learner 'classif.featureless' on task 'sonar' (iter 3/3)
#> INFO  [12:00:51.469] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 1/3)
#> INFO  [12:00:52.269] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 2/3)
#> INFO  [12:00:52.672] [mlr3] Applying learner 'lasso' on task 'sonar' (iter 3/3)
#> INFO  [12:00:52.940] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 1/3)
#> INFO  [12:00:53.052] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 2/3)
#> INFO  [12:00:53.158] [mlr3] Applying learner 'ridge' on task 'sonar' (iter 3/3)
#> INFO  [12:00:53.272] [mlr3] Finished benchmark

print(bmr)
#> <BenchmarkResult> of 9 rows with 3 resampling runs
#>  nr task_id          learner_id resampling_id iters warnings errors
#>   1   sonar classif.featureless            cv     3        0      0
#>   2   sonar               lasso            cv     3        0      0
#>   3   sonar               ridge            cv     3        0      0

# get classification error
bmr$aggregate(measures = msr("classif.ce"))
#>       nr task_id          learner_id resampling_id iters classif.ce
#>    <int>  <char>              <char>        <char> <int>      <num>
#> 1:     1   sonar classif.featureless            cv     3  0.4663906
#> 2:     2   sonar               lasso            cv     3  0.2692892
#> 3:     3   sonar               ridge            cv     3  0.2354727
#> Hidden columns: resample_result

# get aic
bmr$aggregate(measures = msr("aic"))
#>       nr task_id          learner_id resampling_id iters   aic
#>    <int>  <char>              <char>        <char> <int> <num>
#> 1:     1   sonar classif.featureless            cv     3    NA
#> 2:     2   sonar               lasso            cv     3    NA
#> 3:     3   sonar               ridge            cv     3    NA
#> Hidden columns: resample_result

Created on 2024-08-16 with reprex v2.1.1

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.4.1 (2024-06-14) #> os macOS Sonoma 14.5 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Rome #> date 2024-08-16 #> pandoc 3.1.11 @ /System/Volumes/Data/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> backports 1.5.0 2024-05-23 [1] CRAN (R 4.4.0) #> checkmate 2.3.2 2024-07-29 [1] CRAN (R 4.4.0) #> cli 3.6.3 2024-06-21 [1] CRAN (R 4.4.0) #> codetools 0.2-20 2024-03-31 [2] CRAN (R 4.4.1) #> crayon 1.5.3 2024-06-20 [1] CRAN (R 4.4.0) #> data.table 1.15.4 2024-03-30 [1] CRAN (R 4.4.0) #> digest 0.6.36 2024-06-23 [1] CRAN (R 4.4.0) #> evaluate 0.24.0 2024-06-10 [1] CRAN (R 4.4.0) #> fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.0) #> foreach 1.5.2 2022-02-02 [1] CRAN (R 4.4.0) #> fs 1.6.4 2024-04-25 [1] CRAN (R 4.4.0) #> future 1.34.0 2024-07-29 [1] CRAN (R 4.4.0) #> future.apply 1.11.2 2024-03-28 [1] CRAN (R 4.4.0) #> glmnet 4.1-8 2023-08-22 [1] CRAN (R 4.4.0) #> globals 0.16.3 2024-03-08 [1] CRAN (R 4.4.0) #> glue 1.7.0 2024-01-09 [1] CRAN (R 4.4.0) #> htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0) #> iterators 1.0.14 2022-02-05 [1] CRAN (R 4.4.0) #> knitr 1.48 2024-07-07 [1] CRAN (R 4.4.0) #> lattice 0.22-6 2024-03-20 [2] CRAN (R 4.4.1) #> lgr 0.4.4 2022-09-05 [1] CRAN (R 4.4.0) #> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.0) #> listenv 0.9.1 2024-01-29 [1] CRAN (R 4.4.0) #> Matrix 1.7-0 2024-04-26 [2] CRAN (R 4.4.1) #> mlr3 * 0.20.2 2024-07-29 [1] CRAN (R 4.4.0) #> mlr3learners * 0.7.0 2024-06-28 [1] CRAN (R 4.4.0) #> mlr3measures 0.6.0 2024-07-21 [1] CRAN (R 4.4.0) #> mlr3misc 0.15.1 2024-06-24 [1] CRAN (R 4.4.0) #> mlr3pipelines * 0.6.0 2024-07-01 [1] CRAN (R 4.4.0) #> palmerpenguins 0.1.1 2022-08-15 [1] CRAN (R 4.4.0) #> paradox 1.0.1 2024-07-09 [1] CRAN (R 4.4.0) #> parallelly 1.38.0 2024-07-27 [1] CRAN (R 4.4.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.4.0) #> Rcpp 1.0.13 2024-07-17 [1] CRAN (R 4.4.0) #> reprex 2.1.1 2024-07-06 [1] CRAN (R 4.4.0) #> rlang 1.1.4 2024-06-04 [1] CRAN (R 4.4.0) #> rmarkdown 2.27 2024-05-17 [1] CRAN (R 4.4.0) #> rstudioapi 0.16.0 2024-03-24 [1] CRAN (R 4.4.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.4.0) #> shape 1.4.6.1 2024-02-23 [1] CRAN (R 4.4.0) #> survival 3.7-0 2024-06-05 [1] CRAN (R 4.4.0) #> uuid 1.2-1 2024-07-29 [1] CRAN (R 4.4.0) #> withr 3.0.1 2024-07-31 [1] CRAN (R 4.4.0) #> xfun 0.46 2024-07-18 [1] CRAN (R 4.4.0) #> yaml 2.3.10 2024-07-26 [1] CRAN (R 4.4.0) #> #> [1] /Users/Lukas/Library/R/arm64/4.4/library #> [2] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

AIC in this context can not be calculated because AIC checks if the learner provides a loglik:

   if ("loglik" %nin% learner$properties) {
        return(NA_real_)
    }

which appears to be false for all the learners in this example. Using plain logistic regression, we at least get an AIC value:

library(mlr3)
library(mlr3learners)
library(mlr3pipelines)

# define task
task = tsk("sonar")

learner_logreg = po("learner", lrn("classif.log_reg", id = "logreg"))
graph_logreg = learner_logreg
graph_logreg = as_learner(graph_logreg)

# define resampling
resampling = rsmp("cv", folds = 3)

rr = resample(
  task = task,
  learner = graph_logreg,
  resampling = resampling,
  store_models = TRUE
)
#> INFO  [12:12:05.195] [mlr3] Applying learner 'logreg' on task 'sonar' (iter 1/3)
#> INFO  [12:12:05.331] [mlr3] Applying learner 'logreg' on task 'sonar' (iter 2/3)
#> INFO  [12:12:05.386] [mlr3] Applying learner 'logreg' on task 'sonar' (iter 3/3)
#> Warning: glm.fit: algorithm did not converge
#> This happened PipeOp logreg's $train()
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> This happened PipeOp logreg's $train()
#> Warning: glm.fit: algorithm did not converge
#> This happened PipeOp logreg's $train()
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> This happened PipeOp logreg's $train()
#> Warning: glm.fit: algorithm did not converge
#> This happened PipeOp logreg's $train()
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> This happened PipeOp logreg's $train()

print(rr)
#> <ResampleResult> with 3 resampling iterations
#>  task_id learner_id resampling_id iteration warnings errors
#>    sonar     logreg            cv         1        0      0
#>    sonar     logreg            cv         2        0      0
#>    sonar     logreg            cv         3        0      0

# get classification error
rr$aggregate(measures = msr("classif.ce"))
#> classif.ce 
#>   0.279089

# get aic
rr$aggregate(measures = msr("aic"))
#> aic 
#> 122

Created on 2024-08-16 with reprex v2.1.1