Search code examples
rcalibrationmlr3

how to draw a calibration plot of a binary classifier in mlr3


In mlr there was a function to draw calibration plots:

## mlr approach
# train predict
library(mlr)
lrn = makeLearner("classif.rpart", predict.type = "prob")
mod = train(lrn, task = sonar.task)
pred = predict(mod, task = sonar.task)

# make calibration plot
cal = generateCalibrationData(pred)
plotCalibration(cal, smooth=TRUE)
#> `geom_smooth()` using formula 'y ~ x'

Now I wonder how I could draw a nice calibration plot in mlr3 using the output of learner$train(task)$predict(task). I did not find this topic in the mlr3 book. Any hint is very appreciated.

## mlr3 approach
# train/predict
library(mlr3)

data("Sonar", package = "mlbench")
task = TaskClassif$new(id = "Sonar", Sonar, target = "Class", positive = "R")
learner = lrn("classif.rpart", predict_type = "prob")
pred = learner$train(task)$predict(task)

Created on 2021-03-26 by the reprex package (v1.0.0)


Solution

  • According to jakob-r's comment, this function is not yet available in mlr3. It might become available in mlr3.