nb: Calculate the net benefit of a model at a given probability...

View source: R/nb.R

nbR Documentation

Calculate the net benefit of a model at a given probability threshold.

Description

Calculate the net benefit of a model at a given probability threshold.

Usage

nb(preds, obs, p_t, weight = NULL)

Arguments

preds

A vector of predicted probabilities.

obs

A vector containing the observed binary outcomes (0 or 1).

p_t

The probability threshold at or above which a prediction is considered to be positive.

weight

Relative weighted importance of true positives to false positives independent of the classification threshold. When weight = NULL, the original net benefit calculation is used. Default = NULL

Value

The true positive count is the number of observations predicted as positive that are indeed positive.

Examples

# Generate some predictions
predictions <- runif(1000)
# Generate some binary outcomes
observations <- sample(0:1, size = 1000, replace = TRUE)
# Calculate the true positive count
nb(predictions, observations, p_t = 0.25)

gweissman/gmish documentation built on Feb. 16, 2025, 8:38 a.m.