compute_metrics: Compute several metrics for classification tasks.

Description Usage Arguments Value See Also Examples

View source: R/metrics.R

Description

Compute the following metrics: "Accuracy", "Precision", "Recall", "Specificity", "NPV" and "F1".

Usage

1
2
compute_metrics(data, threshold = 0.5, obs = "obs", prob = "prob",
  pos_class = "Yes", neg_class = "No")

Arguments

data

A dataframe with the observed and the predicted class.

threshold

A numerical value or a sequence of numerical values (default = 0.5). The threshold(s) to compute the metrics.

obs

A string (default = "obs"). The column's name of the observed class.

prob

A string (default = "prob"). The column's name of the predicted probabilities.

pos_class

A string (default = "Yes"). How the positive class is coded.

neg_class

A string (default = "No"). How the negative class is coded.

Value

A dataframe with the computed metrics.

See Also

compute_predict_class, compute_optimal_threshold, objective_threshold

Examples

1
2
3
4
5
6
7
8
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))
)

compute_metrics(data, threshold = 0.5)
compute_metrics(data, threshold = seq(0, 1, 0.1))

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