classError: Classification error

Description Usage Arguments Details Value See Also Examples

View source: R/util.R View source: R/mclustda.R

Description

Error for a given classification relative to a known truth. Location of errors in a given classification relative to a known truth.

Usage

1
classError(classification, truth)

Arguments

classification

A numeric or character vector of class labels.

truth

A numeric or character vector of class labels. Must have the same length as classification.

Details

If more than one mapping between classification and truth corresponds to the minimum number of classification errors, only one possible set of misclassified observations is returned.

Value

A list with the following two components:

misclassified

The indexes of the misclassified data points in a minimum error mapping between the given classification and the given truth.

errorRate

The errorRate corresponding to a minimum error mapping mapping between the given classification and the given truth.

See Also

mapClass, table

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
a <- rep(1:3, 3)
a
b <- rep(c("A", "B", "C"), 3)
b
classError(a, b)

a <- sample(1:3, 9, replace = TRUE)
a
b <- sample(c("A", "B", "C"), 9, replace = TRUE)
b
classError(a, b)

Example output

Package 'mclust' version 5.3
Type 'citation("mclust")' for citing this R package in publications.
[1] 1 2 3 1 2 3 1 2 3
[1] "A" "B" "C" "A" "B" "C" "A" "B" "C"
$misclassified
integer(0)

$errorRate
[1] 0

[1] 1 1 3 2 2 1 1 2 1
[1] "A" "B" "B" "A" "A" "C" "C" "B" "C"
$misclassified
[1] 1 3 8

$errorRate
[1] 0.3333333

mclust documentation built on Nov. 22, 2017, 5:05 p.m.