specificity: Calculate Specificity (True Negative Rate)

specificityR Documentation

Calculate Specificity (True Negative Rate)

Description

Calculates Specificity, also known as the True Negative Rate (TNR), which is the proportion of actual negatives that are correctly identified as such by the classifier. Specificity is a key measure in evaluating the effectiveness of a classifier in identifying negative instances.

Usage

dx_specificity(cm, detail = "full", ...)

dx_tnr(cm, detail = "full", ...)

Arguments

cm

A dx_cm object created by dx_cm().

detail

Character specifying the level of detail in the output: "simple" for raw estimate, "full" for detailed estimate including 95% confidence intervals.

...

Additional arguments to pass to metric_binomial function, such as citype for type of confidence interval method.

Details

Specificity or TNR measures how well the classifier can identify negative instances, which is critical in situations where false positives carry a high cost. A higher specificity indicates a better performance in recognizing negative instances and avoiding false alarms.

The formula for Specificity is:

Specificity = \frac{True Negatives}{True Negatives + False Positives}

Value

Depending on the detail parameter, returns a numeric value representing the calculated metric or a data frame/tibble with detailed diagnostics including confidence intervals and possibly other metrics relevant to understanding the metric.

See Also

dx_cm() to understand how to create and interact with a 'dx_cm' object.

Examples

cm <- dx_cm(dx_heart_failure$predicted, dx_heart_failure$truth,
  threshold =
    0.5, poslabel = 1
)
simple_specificity <- dx_specificity(cm, detail = "simple")
detailed_specificity <- dx_specificity(cm)
print(simple_specificity)
print(detailed_specificity)

overdodactyl/diagnosticSummary documentation built on Jan. 28, 2024, 10:07 a.m.