Description Usage Arguments Value Examples
View source: R/classificationErrors.R
classificationErrors
builds confusion matrix from manually coded
and predicted gender vectors and returns
classification errors calculated on that matrix.
1 | classificationErrors(labels, predictions)
|
labels |
A vector of true labels. Should have following
values: c("female", "male", "unknown", "noname"). |
predictions |
A vector of predicted gender. Should have following
values: c("female", "male", NA). |
A list of gender prediction efficiency indicators:
Full confusion matrix.
Total classification error calculated on the matrix.
Classification error calculated without "noname" category.
Classification error calculated without both "noname" and "unknown" category.
Classification error calculated only on "female" and "male" categories from both predictions and labels.
Total proportion of items with unpredicted gender.
Proportion of items with unpredicted gender calculated without "noname" category.
Proportion of items with unpredicted gender calculated without both "noname" and "unknown" category.
Calculated as follows: "male" classified as "female" minus "female" classified as "male" and divided by the sum of items in "female" and "male" categories from both predictions and labels.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | suppressWarnings(RNGversion("3.5.0"))
set.seed(23)
labels = sample(c("female", "male", "unknown", "noname"), 100, replace = TRUE)
predictions = sample(c("female", "male", NA), 100, replace = TRUE)
classificationErrors(labels, predictions)
# $confMatrix
# predictions
# labels female male <NA>
# female 6 6 8
# male 6 10 10
# noname 12 6 17
# unknown 5 7 7
# <NA> 0 0 0
#
# $errorTotal
# [1] 0.67
#
# $errorFullFirstNames
# [1] 0.6461538
#
# $errorCoded
# [1] 0.6521739
#
# $errorCodedWithoutNA
# [1] 0.4285714
#
# $naTotal
# [1] 0.42
#
# $naFullFirstNames
# [1] 0.3846154
#
# $naCoded
# [1] 0.3913043
#
# $errorGenderBias
# [1] 0
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.