mlr-org / mlr3

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

Measure `"time_train"` does currently not take the time for the fallback learner into account #1161

Closed sebffischer closed 3 weeks ago

sebffischer commented 2 months ago

Below, we conduct a resample experiment where a fallback learner is triggered.

If we afterwards evaluate the train time via a measure, we only get the time of the primary learner (which failed), but not the time needed to train the fallback learner.

library(mlr3verse)
#> Loading required package: mlr3

l = lrn("classif.debug", error_train = 1, fallback = lrn("classif.rpart"), encapsulate = c(train = "callr"))

rr = resample(tsk("iris"), l, rsmp("holdout"))
#> INFO  [13:51:45.307] [mlr3] Applying learner 'classif.debug' on task 'iris' (iter 1/1)
#> ERROR [13:51:45.997] [mlr3] train: Error from classif.debug->train()

rr$aggregate(msr("time_train"))
#> time_train 
#>      0.652
rr$learners[[1L]]$state$train_time
#> elapsed 
#>   0.652
rr$learners[[1L]]$state$fallback_state$train_time
#> [1] 0.005

Created on 2024-09-03 with reprex v2.0.2

berndbischl commented 1 month ago

@sebffischer : can you come where with ANY scenario where you would even like to look at these times? i would tend to say: doc with one extra sentence what happens here but dont change

sebffischer commented 1 month ago

Changing docs is fine for me. I think I just raised this issue because it was not properly specified/

be-marc commented 3 weeks ago

Done 5d9441f1daba939e3513186b19c6248e29251665