Setting cluster id in MClust

54 views Asked by At

When I cluster a dataset using MClust, I use the following code-

i = 2
print(paste("Number of clusters =", i))
cluster_model1 <- Mclust(cc[2:6], G=i)

When I repeat the clustering, the cluster classification (id) in each iteration can remain the same or it can change from 1 to 2 or 2 to 1. Is it possible to set the cluster id so that it does not change arbitrarily. I want to see how many times data from 10 imputed datasets belongs to cluster 1 or cluster 2. I can calculate this only if the cluster id remains the same.

The dataset cc has this data

head(cc[2:6])
              ea             pa           sa                en               pn
1             1.0            1.0          1.0               2.2              1.6
2             3.2            2.4          1.0               3.2              1.8
3             1.2            1.0          1.0               2.0              1.0
4             1.6            1.2          1.2               1.0              1.2
5             3.6            1.0          1.6               4.0              2.6
6             1.6            1.0          1.4               1.4              1.2

When I cluster, the classification could be

head(cluster_model1$classification)
[1] 2 1 2 1 1 1

or

head(cluster_model1$classification)
[1] 1 2 1 2 2 2

While the clustering results are correct, is it possible to set it as 2 1 2 1 1 1 every time the clustering is done.

0

There are 0 answers