# NOT RUN {
# The data fgkm.sample has 600 objects and 50 dimensions.
# Scale the data before clustering
x <- scale(fgkm.sample)
# Group information is formated as below.
# Each group is separated by ';'.
strGroup <- "0-9;10-19;20-49"
groups <- c(rep(0, 10), rep(1, 10), rep(2, 30))
# Use the fgkm algorithm.
myfgkm <- fgkm(x, 3, strGroup, 3, 1, seed=19)
myfgkm2 <- fgkm(x, 3, groups, 3, 1, seed=19)
all.equal(myfgkm, myfgkm2)
# You can print the clustering result now.
myfgkm$cluster
myfgkm$featureWeight
myfgkm$groupWeight
myfgkm$iterations
myfgkm$restarts
myfgkm$totiters
myfgkm$totss
# Use a cluster validation method from package 'fpc'.
# real.cluster is the real class label of the data 'fgkm.sample'.
real.cluster <- rep(1:3, each=200)
# cluster.stats() computes several distance based statistics.
kmstats <- cluster.stats(d=dist(x), as.integer(myfgkm$cluster), real.cluster)
# corrected Rand index
kmstats$corrected.rand
# variation of information (VI) index
kmstats$vi
# }
Run the code above in your browser using DataLab