## 1. FowlkesMallowsIndex (adjusted) with the two vectors as input
c <- matrix(c(1, 1, 1, 2, 2, 1,2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3),
ncol=2, byrow=TRUE)
## c1 - numeric vector containing the labels of the first partition
c1 <- c[, 1]
## c2 - numeric vector containing the labels of the second partition
c2 <- c[, 2]
(FM <- FowlkesMallowsIndex(c1, c2))
## 2. FM index (adjusted) with the contingency table as input.
T <- matrix(c(1, 1, 0, 1, 2, 1, 0, 0, 4), ncol=3, byrow=TRUE)
(FM <- FowlkesMallowsIndex(T))
## 3. Compare FM (unadjusted) for iris data (true classification against
## tclust classification).
## First partition c1 is the true partition
c1 <- iris$Species
## Second partition c2 is the output of tclust clustering procedure
out <- tclust(iris[, 1:4], k=3, alpha=0, restr.fact=100)
c2<- out$cluster
(FM <- FowlkesMallowsIndex(c1, c2))
## 4. Compare FM index (unadjusted) for iris data (exclude unassigned units from tclust).
## First partition c1 is the true partition
c1 <- iris$Species
## Second partition c2 is the output of tclust clustering procedure
out <- tclust(iris[, 1:4], k=3, alpha=0.1, restr.fact=100)
c2<- out$cluster
## Units inside c2 which contain number 0 are referred to trimmed observations
noisecluster <- 0
(FM <- FowlkesMallowsIndex(c1, c2, noisecluster=noisecluster))
Run the code above in your browser using DataLab