Recall | Sensitivity | True Positive Rate | Hit rate
Recall | Sensitivity | True Positive Rate | Hit rate
recall estimates the recall (a.k.a. sensitivity, true positive rate -TPR-, or hit rate) for a nominal/categorical predicted-observed dataset.
TPR alternative to recall().
sensitivity alternative to recall().
hitrate alternative to recall().
FNR estimates false negative rate (or false alarm, or fall-out) for a nominal/categorical predicted-observed dataset.
recall( data =NULL, obs, pred, atom =FALSE, pos_level =2, tidy =FALSE, na.rm =TRUE)TPR( data =NULL, obs, pred, atom =FALSE, pos_level =2, tidy =FALSE, na.rm =TRUE)sensitivity( data =NULL, obs, pred, atom =FALSE, pos_level =2, tidy =FALSE, na.rm =TRUE)hitrate( data =NULL, obs, pred, atom =FALSE, pos_level =2, tidy =FALSE, na.rm =TRUE)FNR( data =NULL, obs, pred, atom =FALSE, pos_level =2, 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).
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.
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.
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.
Returns
an object of class numeric within a list (if tidy = FALSE) or within a data frame (if tidy = TRUE).
Details
The recall (a.k.a. sensitivity or true positive rate -TPR-) is a non-normalized coefficient that represents the ratio between the correctly predicted cases (true positives -TP-) to the total number of actual observations that belong to a given class (actual positives -P-).
For binomial cases, recall=PTP=TP+FNTP
The recall metric is bounded between 0 and 1. The closer to 1 the better. Values towards zero indicate low performance. It can be either estimated for each particular class or at a global level.
Metrica offers 4 identical alternative functions that do the same job: i) recall, ii) sensitivity, iii) TPR, and iv) hitrate. However, consider when using metrics_summary, only the recall alternative is used.
The false negative rate (or false alarm, or fall-out) is the complement of the recall, representing the ratio between the number of false negatives (FN) to the actual number of positives (P). The FNR formula is:
FNR=1−recall=1−TPR=PFN
The fpr is bounded between 0 and 1. The closer to 0 the better. Low performance is indicated with fpr > 0.5.
set.seed(123)# Two-classbinomial_case <- data.frame(labels = sample(c("True","False"),100,replace =TRUE), predictions = sample(c("True","False"),100, replace =TRUE))# Multi-classmultinomial_case <- data.frame(labels = sample(c("Red","Blue","Green"),100,replace =TRUE), predictions = sample(c("Red","Blue","Green"),100, replace =TRUE))# Get recall estimate for two-class case at global levelrecall(data = binomial_case, obs = labels, pred = predictions, tidy =TRUE)# Get FNR estimate for two-class case at global levelFNR(data = binomial_case, obs = labels, pred = predictions, tidy =TRUE)# Get recall estimate for each class for the multi-class case at global levelrecall(data = multinomial_case, obs = labels, pred = predictions, tidy =TRUE,atom =FALSE)# Get recall estimate for the multi-class case at a class-levelrecall(data = multinomial_case, obs = labels, pred = predictions, tidy =TRUE,atom =TRUE)
References
Ting K.M. (2017) Precision and Recall. In: Sammut C., Webb G.I. (eds) Encyclopedia of Machine Learning and Data Mining.