brier_score: Brier Score

View source: R/metrics.R

brier_scoreR Documentation

Brier Score

Description

Given the observed values and the predicted probabilites of categorical data (of at least two classes) computes the Brier Score.

Usage

brier_score(observed, probabilities, remove_na = TRUE)

Arguments

observed

(factor) The observed values. It has to have the same length as rows probabilities.

probabilities

(data.frame) The probability of each class for each individual. It is required the columns names of probabilities corresponds to all classes (levels) in observed and that probabilities has as many rows as records observed.

remove_na

(logical(1)) Should NA values be removed?. TRUE by default.

Details

Brier score is computed as:

(1 / N) *  sum(sum((f_{ti} - o_{ti})^2))

Where R is the number of possible classes in which the event can fall, and N the overall number of instances of all classes. f_ti is the predicted probability for class i. o_ti is 1 if it is i-th class in instant t, 0 otherwise.

Value

A single numeric value with the Brier Score.

See Also

Other categorical_metrics: accuracy(), categorical_summary(), confusion_matrix(), f1_score(), kappa_coeff(), math_mode(), matthews_coeff(), pccc(), pcic(), pr_auc(), precision(), recall(), roc_auc(), sensitivity(), specificity()

Examples

## Not run: 
probs <- data.frame(a = c(0.7, 0.2), b = c(0.3, 0.8))
brier_score(factor(c("a", "b")), probs)

probs <- data.frame(
  a = c(0.2, 0.8, 0.3),
  b = c(0.3, 0.1, 0.3),
  c = c(0.5, 0.1, 0.4),
)

brier_score(factor(c("a", "a", "c")), probs)


probs <- data.frame(a = 1, b = 0)
brier_score("a", probs)

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.