其中mlr
有一个绘制校准图的功能:
## 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'
现在我想知道如何在mlr3
使用learner$train(task)$predict(task)
. 我在 mlr3 书中没有找到这个主题。任何提示都非常感谢。
## 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)
由reprex 包于 2021-03-26 创建(v1.0.0)