Skip to content

Autplot for Benchmarking (Change order of boxplots/tasks) #88

Open
@FionaKunz

Description

Hi!

Plotting my benchmark results, I would like to change the order of the boxplots from alphabetical order (default in autoplot function?) to another order.
So far, I was able to change the respective task's boxplots the following way (see code).
However, since recently, changing the levels of the task_id-factor variable, only changes the order of the title, but not the respective boxplots themselves.

How can I change the order of the boxplots?
Any help highly appreciated! Thanks a lot


library(mlr3)
library(mlr3viz)

tasks = tsks(c("pima", "sonar"))
learner = lrns(c("classif.featureless", "classif.rpart"),
               predict_type = "prob")
resampling = rsmps("cv")
bmr = benchmark(benchmark_grid(tasks, learner, resampling))

# AUC
bmr_boxplots_auc <- autoplot(bmr, measure = msr("classif.auc")) + 
  ggplot2::theme(axis.text.x = ggplot2::element_text(hjust = .5)) + 
  ggplot2::scale_x_discrete(labels =c("FL", "RF", "LR"))+
  ggplot2::ylab("AUC")+
  ggplot2::xlab("Learner")+
  ggplot2::theme_bw()+
  ggplot2::theme(panel.grid = element_blank(),
                 strip.background = element_blank()
  )
bmr_boxplots_auc
bmr_boxplots_auc$data$task_id <- as.factor(bmr_boxplots_auc$data$task_id) 
levels(bmr_boxplots_auc$data$task_id) = c("sonar", "pima")
bmr_boxplots_auc

Bildschirmfoto 2021-11-24 um 18 00 22

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions