y_true_ex <- factor(c("Negative", "Positive", "Positive", "Negative", "Positive"),
levels = c("Negative", "Positive"))
prob_ex <- c(0.1, 0.8, 0.6, 0.3, 0.9)
# Find threshold maximizing F1-score
opt_f1_threshold <- find_optimal_threshold_dia(
prob_positive = prob_ex,
y_true = y_true_ex,
type = "f1",
pos_class = "Positive",
neg_class = "Negative"
)
print(opt_f1_threshold)
# Find threshold maximizing Youden's J
opt_youden_threshold <- find_optimal_threshold_dia(
prob_positive = prob_ex,
y_true = y_true_ex,
type = "youden",
pos_class = "Positive",
neg_class = "Negative"
)
print(opt_youden_threshold)
Run the code above in your browser using DataLab