rank_score: Calculate Rank Score for Predictions

View source: R/classifier.R

rank_scoreR Documentation

Calculate Rank Score for Predictions

Description

Computes the rank score (normalized rank of the true class probability) for each observation. Lower rank scores indicate better predictions (true class has higher probability).

Usage

rank_score(prob, observed)

Arguments

prob

Numeric matrix of predicted probabilities (observations x classes). Column names must correspond to class labels.

observed

Factor or vector of observed class labels. Must be present in colnames(prob).

Value

A data.frame with columns prank (the normalized rank score) and observed (the input labels).

See Also

Other classifier evaluation: topk()

Examples

probs <- matrix(c(0.1, 0.9, 0.8, 0.2), 2, 2, byrow=TRUE,
               dimnames = list(NULL, c("A", "B")))
obs <- factor(c("B", "A"))
rank_score(probs, obs)

bbuchsbaum/multivarious documentation built on July 16, 2025, 11:04 p.m.