Title: EM test

Summary: Model based clustering:Expectation Maximization

Using the mclust package, No need to provide number of clusters

Libraries

Libraries = c("readr", "mclust", "clusteval", "knitr", "rgl")

# Install if not present
for(p in Libraries){
    if(!require(p, character.only = TRUE)) { install.packages(p, dependencies = T) }
    library(p, character.only = TRUE)
}

Import Iris Data

data(iris)
Iris_data  <- iris[,-5]
Iris_class <- iris[, 5]

Calculate BIC

iris_BIC <- mclustBIC(Iris_data)

Plot #1

Plot the Values for BIC with respect to Iris data

plot(iris_BIC)

model <- Mclust(Iris_data, x = iris_BIC)
cluster_similarity(model$classification, 
                   Iris_class, 
                   similarity = "rand")
## [1] 0.7762864

Plot #2

Link_EM <- mclustBIC(Iris_data)

plot(Link_EM)

Calculation and 3D Plot

knit_hooks$set(webgl = hook_webgl)
mfrow3d(nr = 1, nc = 2, sharedMouse = T)  

plot3d((Iris_data),
       col = model$classification, 
       type = "s",
       radius = 0.1, 
       main = "EM")  

Iris_class <- factor(Iris_class)
plot3d((Iris_data),
       col = list(setosa = "blue", 
                  versicolor = "red", 
                  virginica = "black"), 
       type = "s",
       radius=0.1, 
       main="Ground Truth") 

rglwidget()

Machine Settings

Sys.info()[c(1:3,5)]
##                                              sysname 
##                                              "Linux" 
##                                              release 
##                                  "4.15.0-48-generic" 
##                                              version 
## "#51~16.04.1-Ubuntu SMP Fri Apr 5 12:01:12 UTC 2019" 
##                                              machine 
##                                             "x86_64"

Session Info

sessionInfo()
## R version 3.4.4 (2018-03-15)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Linux Mint 18.3
## 
## Matrix products: default
## BLAS: /usr/lib/libblas/libblas.so.3.6.0
## LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
## [1] rgl_0.100.19     knitr_1.22       clusteval_0.1    mclust_5.4.3    
## [5] doMC_1.3.5       iterators_1.0.10 foreach_1.4.4    readr_1.3.1     
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.1              pillar_1.3.1           
##  [3] compiler_3.4.4          later_0.8.0            
##  [5] tools_3.4.4             digest_0.6.18          
##  [7] jsonlite_1.6            evaluate_0.13          
##  [9] tibble_2.1.1            pkgconfig_2.0.2        
## [11] rlang_0.3.4             shiny_1.3.2            
## [13] crosstalk_1.0.0         yaml_2.2.0             
## [15] mvtnorm_1.0-8           xfun_0.6               
## [17] stringr_1.4.0           htmlwidgets_1.3        
## [19] hms_0.4.2               webshot_0.5.1          
## [21] manipulateWidget_0.10.0 R6_2.4.0               
## [23] rmarkdown_1.12          magrittr_1.5           
## [25] codetools_0.2-16        promises_1.0.1         
## [27] htmltools_0.3.6         mime_0.6               
## [29] xtable_1.8-4            httpuv_1.5.1           
## [31] miniUI_0.1.1.1          stringi_1.4.3          
## [33] crayon_1.3.4

EOF