Learn R Programming

genderizeR (version 2.0.0)

classificationErrors: Calculating classification errors and other prediction indicators

Description

classificationErrors builds confusion matrix from manually coded and predicted gender vectors and returns different specific classification errors calculated on that matrix.

Usage

classificationErrors(labels, predictions)

Arguments

labels

A vector of true labels. Should have following values: c("female", "male", "unknown", "noname"). noname stands also for initials only.

predictions

A vector of predicted gender. Should have following values: c("female", "male", NA). NA when it was not possible to predict any gender.

Value

A list of gender prediction efficency indicators:

confMatrix

full confusion matrix

errorTotal

total classification error

errorFullFirstNames

classification error without "noname" category

errorCoded

classification error without both "noname" and "unknown" category

errorCodedWithoutNA

classification error only on "female" and "male" categories in both predictions and labels

naTotal

total proportion of items with unpredicted gender

naFullFirstNames

proportion of items with unpredicted gender without "noname" category

naCoded

proportion of items with unpredicted gender without both "noname" and "unknown" category

errorGenderBias

"male" classified as "female" minus "female" classifed as "male" and divided by the sum of items in "female" and "male" categories in both predictions and labels

Examples

Run this code
# NOT RUN {
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)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab