threshperf: Calculates threshold-performance data

View source: R/threshperf_plots.R

threshperfR Documentation

Calculates threshold-performance data

Description

This function is used by the threshperf_plot function. This is based on the threshold_perf() function from the probably package (a part of tidymodels) but expands the capability to allow for the range of metrics to include positive and negative predictive value.

Usage

threshperf(
  df,
  outcome,
  prediction,
  positive = "has_sepsis",
  thresholds = NULL,
  statistics = c("sens", "spec", "ppv", "npv"),
  prevalence = NULL
)

Arguments

df

The df as a data.frame.

outcome

A character string containing the name of the column containing the outcomes (expressed as 0/1s).

prediction

A character string containing the name of the column containing the predictions.

thresholds

Numeric vector of thresholds at which the performance statistics are calculated. Default is NULL, which returns performance statistics at each observed prediction level.

statistics

Character vector of statistics to include. Select among c("sens", "spec", "ppv", "npv", "test_pos_rate", "test_neg_rate", "tp_rate", "tn_rate", "fn_rate", "fp_rate", "prevalence"). Default is c("sens", "spec", "ppv", "npv").

prevalence

Specify the prevalence of outcome for case-control studies. Default is NULL and the prevalence will be estimated from data.

Value

A data.frame containing the columns .threshold, .metric, .estimator, and .estimate

Examples

data(single_model_dataset)
threshperf(single_model_dataset, outcome = 'outcomes', prediction = 'predictions')

ML4LHS/runway documentation built on Sept. 9, 2023, 8:27 p.m.