## S3 method for class 'factor'
recall(actual, predicted, micro = NULL, na.rm = TRUE, ...)
## S3 method for class 'factor'
weighted.recall(actual, predicted, w, micro = NULL, na.rm = TRUE, ...)
## S3 method for class 'cmatrix'
recall(x, micro = NULL, na.rm = TRUE, ...)
## S3 method for class 'factor'
sensitivity(actual, predicted, micro = NULL, na.rm = TRUE, ...)
## S3 method for class 'factor'
weighted.sensitivity(actual, predicted, w, micro = NULL, na.rm = TRUE, ...)
## S3 method for class 'cmatrix'
sensitivity(x, micro = NULL, na.rm = TRUE, ...)
## S3 method for class 'factor'
tpr(actual, predicted, micro = NULL, na.rm = TRUE, ...)
## S3 method for class 'factor'
weighted.tpr(actual, predicted, w, micro = NULL, na.rm = TRUE, ...)
## S3 method for class 'cmatrix'
tpr(x, micro = NULL, na.rm = TRUE, ...)
## Generic S3 method
recall(
...,micro = NULL,
na.rm = TRUE
)
## Generic S3 method
sensitivity(
...,micro = NULL,
na.rm = TRUE
)
## Generic S3 method
tpr(
...,micro = NULL,
na.rm = TRUE
)
## Generic S3 method
weighted.recall(
...,
w,micro = NULL,
na.rm = TRUE
)
## Generic S3 method
weighted.sensitivity(
...,
w,micro = NULL,
na.rm = TRUE
)
## Generic S3 method
weighted.tpr(
...,
w,micro = NULL,
na.rm = TRUE
)
Recall
recall.factor | R Documentation |
Description
A generic funcion for the Recall. Use weighted.fdr()
for the weighted Recall.
Other names
Sensitivity, True Positive Rate
Usage
Arguments
actual
|
A vector of |
predicted
|
A vector of |
micro
|
A |
na.rm
|
A |
…
|
micro = NULL, na.rm = TRUE Arguments passed into other methods |
w
|
A |
x
|
A confusion matrix created |
Value
If micro
is NULL (the default), a named <numeric>
-vector of length k
If micro
is TRUE or FALSE, a <numeric>
-vector of length 1
Definition
Let \(\hat{\rho} \in [0, 1]\) be the proportion of true positives among the actual positives. The recall of the classifier is calculated as,
\[ \hat{\rho} = \frac{\#TP_k}{\#TP_k + \#FN_k} \]
Where:
-
\(\#TP_k\) is the number of true positives, and
-
\(\#FN_k\) is the number of false negatives.
Examples
# 1) recode Iris
# to binary classification
# problem
$species_num <- as.numeric(
iris$Species == "virginica"
iris
)
# 2) fit the logistic
# regression
<- glm(
model formula = species_num ~ Sepal.Length + Sepal.Width,
data = iris,
family = binomial(
link = "logit"
)
)
# 3) generate predicted
# classes
<- factor(
predicted as.numeric(
predict(model, type = "response") > 0.5
),levels = c(1,0),
labels = c("Virginica", "Others")
)
# 3.1) generate actual
# classes
<- factor(
actual x = iris$species_num,
levels = c(1,0),
labels = c("Virginica", "Others")
)
# 4) evaluate class-wise performance
# using Recall
# 4.1) unweighted Recall
recall(
actual = actual,
predicted = predicted
)
# 4.2) weighted Recall
weighted.recall(
actual = actual,
predicted = predicted,
w = iris$Petal.Length/mean(iris$Petal.Length)
)
# 5) evaluate overall performance
# using micro-averaged Recall
cat(
"Micro-averaged Recall", recall(
actual = actual,
predicted = predicted,
micro = TRUE
),"Micro-averaged Recall (weighted)", weighted.recall(
actual = actual,
predicted = predicted,
w = iris$Petal.Length/mean(iris$Petal.Length),
micro = TRUE
),sep = "\n"
)