From d4e0f4b6b8db28babca64cfcca740394a6b1a3d4 Mon Sep 17 00:00:00 2001 From: Felix Rothe Date: Tue, 28 Mar 2023 18:57:11 +0200 Subject: [PATCH] Fix: tuneThreshold - minimization for measures needing maximization --- R/tuneThreshold.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/tuneThreshold.R b/R/tuneThreshold.R index 7a056a878b..0d4ff24860 100644 --- a/R/tuneThreshold.R +++ b/R/tuneThreshold.R @@ -53,7 +53,7 @@ tuneThreshold = function(pred, measure, task, model, nsub = 20L, control = list( if (ttype == "multilabel" || k > 2) { names(x) = cls } - ifelse(measure$minimize, 1, -1) * performance(setThreshold(pred, x), measure, task, model, simpleaggr = TRUE) + ifelse(measure$minimize, 1, -1) * performance(setThreshold(pred, x), measure, task, model, simpleaggr = TRUE) # always a minimization } if (ttype == "multilabel" || k > 2L) { @@ -68,9 +68,9 @@ tuneThreshold = function(pred, measure, task, model, nsub = 20L, control = list( names(th) = cls perf = or$value } else { # classif with k = 2 - or = optimizeSubInts(f = fitn, lower = 0, upper = 1, maximum = !measure$minimize, nsub = nsub) + or = optimizeSubInts(f = fitn, lower = 0, upper = 1, maximum = FALSE, nsub = nsub) # maximum = false, because callback makes it a minimization th = or[[1]] - perf = or$objective + perf = ifelse(measure$minimize, 1, -1) * or$objective # flip sign if minimization for negative performance measure was done } return(list(th = th, perf = perf)) }