mlr-org / mlr3pipelines

Dataflow Programming for Machine Learning in R
https://mlr3pipelines.mlr-org.com/
GNU Lesser General Public License v3.0
140 stars 25 forks source link

po("threshold") cannot set 'prob' #645

Closed loveyu3317 closed 2 months ago

loveyu3317 commented 2 years ago

I want to tune threshold by classif.auc. But when I run the following codes, it cannot set predict_type = "prob".

gr = lrn("classif.rpart", predict_type = "prob") %>>% po("threshold") 
l = as_learner(gr) 
l$predict_type 
loveyu3317 commented 2 years ago

And when I run :

learner$predict_type = 'prob'

it says :

Error in .__PipeOpThreshold__predict_type(self = self, private = private,  : 
  $predict_type for PipeOpThreshold is read-only.
yzm886216 commented 5 months ago

I have the same problem with you.How did you solve it?

mb706 commented 2 months ago

The purpose of the thesholding PipeOp is specifically to turn "prob" predictions into "response" predictions. If you want to have "prob" predictions, you should not use the thresholding PipeOp. However, there may be a reason to have both outputs so that one could use two measures, classif.auc and classif.acc, together? We should discuss this.