0
$\begingroup$

I am developing model-based clustering.

First, I developed model-based clustering in R using "mclust." Next, I wanted to take 75% of the sample, re-run model-based clustering and compare the results with the results from the entire dataset using variation of information or rand index. However, I am getting stuck with the codes.

Here are the codes made available for variation of information on CRAN.

cl1 <-sample(1:30, 10, replace=TRUE)
cl2 <- c(cl1[1:5], sample(1:3, 5, replace=TRUE))
vi.dist(cl1,cl2)
vi.dist(cl1,cl2, parts=TRUE)

Here is how I developed my clustering solutions:

model <-Mclust(data[,18:22])

model based clustering solution using entire dataset and data is the name of my dataset using columns 18 to 22

random <- data[rbinom(nrow(data), 1,.75)==1,]

developed a random sample

randommodel <-Mclust(random[,18:22])

model-based clustering using the random sample

cl1 <- (model$classification)
cl2 <- (randommodel$classification)
vi.dist(cl1,cl2)

my attempt at variation of information using R codes, result failed because cl1 and cl2 are not the same length.

So, how do I make the two solutions the same length given that the two solutions have a different number of observations? Or, am I trying to use variation of information incorrectly?

$\endgroup$
1
$\begingroup$

clustering with entire database

modela <-Mclust(data[,18:22])
summary(modela, parameters = TRUE)
modela$classification
    modela$BIC

clustering using 75% of data

subsample <- sample(1:nrow(data), 530, replace=FALSE)
mysample <-data[subsample,]
modelb <-Mclust(mysample[,18:22])
summary(modelb, parameters = TRUE)
modelb$classification
    modelb$BIC

adjusted rand index

arandi(modela$classification[subsample],modelb$classification)

variation of information

vi.dist(modela$classification[subsample],modelb$classification)
| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Can someone check to see if these codes for comparing the results of clustering when including the entire dataset and when including just 75% of the dataset (i.e., 530 is 75% of the dataset in this case)? $\endgroup$ – user3731653 Dec 4 '14 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.