0

I am using mlr package in R to train my model. I wanted to train my model and do prediction. At the moment I use Recursive Partitioning for Classification and the sample is created using Leave one out method. I want to set the optimum threshold for the prediction.

I have tried using model, and set the threshold value to makeLearner, which did not work as expected.

I tried using MakeParam and tune predict.threshold in Learner, which also did not work properly.

library(mlr)

mlr_data <- as.data.frame(scale(dataset_correlation[,1:154]))
mlr_data$label <- factor(dataset_correlation$label)


task <- makeClassifTask(data = mlr_data,target = "label")
lrnr <- makeLearner("classif.randomForest",predict.type = "prob")
rdesc <- makeResampleDesc("LOO")

ps = makeParamSet(
  makeIntegerParam("predict.threshold", lower = 0.1, upper = 1.0)
)

ctrl = makeTuneControlRandom(tune.threshold = TRUE)
lrn2 = makeTuneWrapper(lrnr, par.set = ps, control = ctrl, resampling = rdesc)
r = resample(lrn2, task, rdesc, extract = getTuneResult)
print(r$extract)

Error:

"Error in checkTunerParset(learner, par.set, measures, control) :

Can only tune parameters for which learner parameters exist: predict.threshold"

I need the threshold to be tuned automatically and use that tune value for prediction.

Got the solution:

check this website https://www.analyticsvidhya.com/blog/2016/08/practicing-machine-learning-techniques-in-r-with-mlr-package/

Community
  • 1
  • 1

0 Answers0