# TODO: Add comment # # Author: mike-bowles ############################################################################### require(mclust) help(mclustModelNames) irisMclust <- Mclust(iris[,-5]) ## Plot BIC for various numbers of components and various types of models plot(irisMclust) ##let's look at the best one based on BIC irisBIC <- mclustBIC(iris[,-5]) plot(irisBIC) mclustModel(iris[,-5], irisBIC) ## Does that correspond to the best one in the graph? ## But that one only picks two components and it classifies them perfectly ## We know that there are 3. Let's see how we do if we force 3 irisBIC <- mclustBIC(iris[,-5],G = 3) #plot(irisBIC) model <- mclustModel(iris[,-5], irisBIC) model index = seq(150) plot(index, model$z[,1]) plot(index, model$z[,2]) plot(index, model$z[,3]) # I count 5 misclassified examples - not bad given that the labels are erased. class <- rep(0.0, 150) for(i in 1:150){ class[i] <- which.max(model$z[i,]) } class