mlr3pipelines icon indicating copy to clipboard operation
mlr3pipelines copied to clipboard

PipeOpTunethreshold fails for measure "classif.costs"

Open sebffischer opened this issue 1 year ago • 0 comments

library(mlr3verse)
#> Loading required package: mlr3
task = tsk("german_credit")
costs = matrix(c(0, 5, 1, 0), nrow = 2)
dimnames(costs) = list(truth = task$class_names, response = task$class_names)

mcost = msr("classif.costs", costs = costs)

graph = po("learner_cv", learner = lrn("classif.rpart", predict_type = "prob")) %>>%
  po("tunethreshold", measure = mcost, optimizer = "random_search")

learner = as_learner(graph)
learner$train(task)
#> INFO  [14:40:12.906] [mlr3] Applying learner 'classif.rpart' on task 'german_credit' (iter 1/3) 
#> INFO  [14:40:13.008] [mlr3] Applying learner 'classif.rpart' on task 'german_credit' (iter 2/3) 
#> INFO  [14:40:13.044] [mlr3] Applying learner 'classif.rpart' on task 'german_credit' (iter 3/3)
#> Error: Measure 'classif.costs' requires a task

Created on 2022-08-02 by the reprex package (v2.0.1)

sebffischer avatar Aug 02 '22 12:08 sebffischer