Learn R Programming

multivarious (version 0.3.1)

rank_score: 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)

Value

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

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).

See Also

Other classifier evaluation: topk()

Examples

Run this code
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)

Run the code above in your browser using DataLab