micro_avg: Calculate the micro-averaged performance of some measure...

View source: R/micro_avg.R

micro_avgR Documentation

Calculate the micro-averaged performance of some measure against a binary outcome across a range of classes in a multi-label classification task.

Description

Calculate the micro-averaged performance of some measure against a binary outcome across a range of classes in a multi-label classification task.

Usage

micro_avg(preds, obs, metric = cstat, ...)

Arguments

preds

A matrix of predicted probabilities for each class.

obs

A matrix containing the observed binary outcomes (0 or 1) for each class. Columns should occur in the same order for 'preds' and 'obs'.

metric

A function name for the performance metric of interest. Default is 'cstat'.

...

Additional parameters that can be passed to 'metric' as needed.

Value

The micro-averaged 'metric' as a single numeric value.

Examples

# Generate some predictions
predictionsA <- runif(1000)
predictionsB <- runif(1000)
# Generate some binary outcomes
observationsA <- sample(0:1, size = 1000, replace = TRUE)
observationsB <- sample(0:1, size = 1000, replace = TRUE)
# Calculate the C-statistic
micro_avg(matrix(c(predictionsA, predictionsB), ncol = 2),
          matrix(c(observationsA, observationsB), ncol = 2))

gweissman/gmish documentation built on Sept. 3, 2024, 11:39 p.m.