compute_optimal_threshold: Compute the optimal threshold for the accuracy or the...

Description Usage Arguments Value See Also Examples

View source: R/metrics.R

Description

Compute the optimal threshold for the accuracy or the F1-score.

Usage

1
compute_optimal_threshold(data, metric = c("Accuracy", "F1"))

Arguments

data

A dataframe with the metrics computed for different thresholds.

metric

A string. The metric to maximize. One of: "Accuracy" or "F1".

Value

A dataframe with the optimal threshold(s).

See Also

compute_predict_class, compute_metrics, objective_threshold

Examples

1
2
3
4
5
6
7
8
9
data <- data.frame(
  obs = c(rep("Yes", 20), rep("No", 20)),
  prob = c(runif(n = 20, min = 0.3, max = 0.8),
           runif(n = 20, min = 0.1, max = 0.6))
)

metrics <- compute_metrics(data, threshold = c(0.3, 0.7, 0.2))

compute_optimal_threshold(metrics, metric = "F1")

thoera/metrics documentation built on Nov. 20, 2019, 2:01 p.m.