nmi: Normalized Mutual Information (NMI)

Description Usage Arguments Source Examples

View source: R/nmi.R

Description

NMI is a normalization of the Mutual Information (MI) score to scale the results between 0 (no mutual information) and 1 (perfect correlation). Can also be used to assess agreement between two clusterings.

Usage

1
nmi(y, yhat)

Arguments

y

actual class labels or predicted cluster labels to compare against

yhat

predicted cluster labels (not necessarily the same absolute values; labels may be permuted)

Source

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
set.seed(0)
clusters <- kmeans(iris[, 1:4], centers = 3)
y <- as.numeric(iris$Species)
yhat <- clusters$cluster
nmi(y, yhat) # 0.76

data("wine")
set.seed(0)
clusters <- kmeans(wine[, -1], centers = 3)
y <- wine$class
yhat <- clusters$cluster
nmi(y, yhat) # 0.43

## End(Not run)

bearloga/dpmclust documentation built on March 7, 2020, 7:11 p.m.