A function to compute the empirical entropy for two vectors of classification and the joint entropy

entropy(c1, c2)

Arguments

c1

a vector containing the labels of the first classification. Must be a vector of characters, integers, numerics, or a factor, but not a list.

c2

a vector containing the labels of the second classification.

Value

a list with the two conditional entropies, the joint entropy and output of sortPairs.

Examples

data(iris)
cl <- cutree(hclust(dist(iris[,-5])), 4)
entropy(cl,iris$Species)
#> $UV
#> [1] 1.543116
#> 
#> $U
#> [1] 1.248086
#> 
#> $V
#> [1] 1.098612
#> 
#> $sortPairs
#> $sortPairs$spMat
#> NULL
#> 
#> $sortPairs$levels
#> $sortPairs$levels$c1
#> [1] 1 2 3 4
#> 
#> $sortPairs$levels$c2
#> [1] setosa     versicolor virginica 
#> Levels: setosa versicolor virginica
#> 
#> 
#> $sortPairs$nij
#> [1] 50 23 37 27  1 12
#> 
#> $sortPairs$ni.
#> [1] 50 60 28 12
#> 
#> $sortPairs$n.j
#> [1] 50 50 50
#> 
#> $sortPairs$pair_c1
#> [1] 0 1 1 2 2 3
#> 
#> $sortPairs$pair_c2
#> [1] 0 1 2 1 2 2
#> 
#>