bmi: Bookmaker Informedness

View source: R/class_bmi.R

bmiR Documentation

Bookmaker Informedness

Description

It estimates the Bookmaker Informedness (a.k.a. Youden's J-index) for a nominal/categorical predicted-observed dataset.

jindex estimates the Youden's J statistic or Youden's J Index (equivalent to Bookmaker Informedness bmi)

Usage

bmi(
  data = NULL,
  obs,
  pred,
  pos_level = 2,
  atom = FALSE,
  tidy = FALSE,
  na.rm = TRUE
)

jindex(
  data = NULL,
  obs,
  pred,
  pos_level = 2,
  atom = FALSE,
  tidy = FALSE,
  na.rm = TRUE
)

Arguments

data

(Optional) argument to call an existing data frame containing the data.

obs

Vector with observed values (character | factor).

pred

Vector with predicted values (character | factor).

pos_level

Integer, for binary cases, indicating the order (1|2) of the level corresponding to the positive. Generally, the positive level is the second (2) since following an alpha-numeric order, the most common pairs are (Negative | Positive), (0 | 1), (FALSE | TRUE). Default : 2.

atom

Logical operator (TRUE/FALSE) to decide if the estimate is made for each class (atom = TRUE) or at a global level (atom = FALSE); Default : FALSE. When dataset is "binomial" atom does not apply.

tidy

Logical operator (TRUE/FALSE) to decide the type of return. TRUE returns a data.frame, FALSE returns a list; Default : FALSE.

na.rm

Logic argument to remove rows with missing values (NA). Default is na.rm = TRUE.

Details

The Bookmaker Informedness (or Youden's J index) it is a suitable metric when the number of cases for each class is uneven.

The general formula applied to both binary and multiclass cases is:

bmi = recall + specificity - 1

It is bounded between 0 and 1. The closer to 1 the better. Values towards zero indicate low performance. For the formula and more details, see online-documentation

Value

an object of class numeric within a list (if tidy = FALSE) or within a ⁠data frame⁠ (if tidy = TRUE).

References

Youden, W.J. (1950). Index for rating diagnostic tests. . Cancer 3: 32-35. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/1097-0142(1950)3:1<32::AID-CNCR2820030106>3.0.CO;2-3")}

Examples


set.seed(123)
# Two-class
binomial_case <- data.frame(labels = sample(c("True","False"), 100, replace = TRUE), 
predictions = sample(c("True","False"), 100, replace = TRUE))
# Multi-class
multinomial_case <- data.frame(labels = sample(c("Red","Blue", "Green"), 100, replace = TRUE),
predictions = sample(c("Red","Blue", "Green"), 100, replace = TRUE)    )

# Get Informedness estimate for two-class case
bmi(data = binomial_case, obs = labels, pred = predictions, tidy = TRUE)

# Get Informedness estimate for each class for the multi-class case
bmi(data = multinomial_case, obs = labels, pred = predictions, tidy = TRUE, atom = TRUE)

# Get Informedness estimate for the multi-class case at a global level
bmi(data = multinomial_case, obs = labels, pred = predictions, tidy = TRUE)


metrica documentation built on June 30, 2024, 5:07 p.m.