
Last chance! 50% off unlimited learning
Sale ends in
Mclust
.## S3 method for class 'Mclust':
predict(object, newdata, \dots)
'Mclust'
resulting from a call to Mclust
.Mclust
are classified.newdata
.newdata
belongs to the kth cluster.C. Fraley, A. E. Raftery, T. B. Murphy and L. Scrucca (2012). mclust Version 4 for R: Normal Mixture Modeling for Model-Based Clustering, Classification, and Density Estimation. Technical Report No. 597, Department of Statistics, University of Washington.
Mclust
.model <- Mclust(faithful)
# predict cluster for the observed data
pred <- predict(model)
str(pred)
pred$z # equal to model$z
pred$classification # equal to
plot(faithful, col = pred$classification, pch = pred$classification)
# predict cluster over a grid
grid <- apply(faithful, 2, function(x) seq(min(x), max(x), length = 50))
grid <- expand.grid(eruptions = grid[,1], waiting = grid[,2])
pred <- predict(model, grid)
plot(grid, col = mclust.options("classPlotColors")[pred$classification], pch = 15, cex = 0.5)
points(faithful, pch = model$classification)
Run the code above in your browser using DataLab