Home > front end >  mlr3 benchmarking with elapsed time measure
mlr3 benchmarking with elapsed time measure

Time:09-27

I am using the mlr3 package in R to create several classification learners and benchmark them on the same binary classification task. I want to evaluate the learners with multiple performance measures: Recall, AUC, accuracy and elapsed time for training.

I am able to perform the benchmarking and get correct results for all measures, except elapsed time, which is reported as 0 for all learners. Below is the code I'm using:

#create task
failure_task <- as_task_classif(df_train, target="Failure")

#select a subset of the features
feat_select <- po("select")
feat_select$param_set$values$selector <- selector_name(feaset_frac)
failure_task <- feat_select$train(list(failure_task))$output

#modify the minority class weight
failure_weight <- po("classweights")
failure_weight$param_set$values$minor_weight=27.73563
failure_task <- failure_weight$train(list(failure_task))[[1L]]

#create resampling
repeat_cv <- rsmp("repeated_cv", folds=5L, repeats=5L)

#create measures
failure_auc <- msr("classif.auc")
failure_rec <- msr("classif.recall")
failure_acc <- msr("classif.acc")
failure_time <- msr("time_train")
list_measures <- list(failure_auc, failure_rec, failure_acc, failure_time)

#create benchmark grid
benchmark_failure = benchmark_grid(tasks=failure_task,
                                  learn=list(glmnet_learner, bayes_learner,
                                             knn_learner, svm_learner, xgb_learner),
                                  resamplings=repeat_cv)

#perform benchmarking
set.seed(1922)
benchmark_failure_res = benchmark(benchmark_failure, store_models=TRUE)

#retrieve average benchmarking results
benchmark_failure_res$aggregate(list_measures)

Am I missing a step that is required to evaluate / record the elapsed time? I looked at the documentation for the elapsed time measure, and the performance evaluation section of the mlr3 book for answers, but couldn't find an answer.

Additional details: I didn't share the code for creating each learner, as I doubt it's relevant, but I can do so if required. I also modified the class weights for some learners that take a class weights argument, such as scale_pos_weight in XGBoost.

CodePudding user response:

I reinstalled mlr3's development version from GitHub after Sebastian's fix, and I confirm the issue is resolved for me.

  • Related