data(dietary_survey_IBS)
dat = dietary_survey_IBS[, -ncol(dietary_survey_IBS)]
dat = center_scale(dat)
clusters = 2
# compute k-means
km = KMeans_rcpp(dat, clusters = clusters, num_init = 5, max_iters = 100, initializer = 'kmeans++')
# compute the silhouette width
silh_km = silhouette_of_clusters(data = dat, clusters = km$clusters)
# silhouette summary
silh_summary = silh_km$silhouette_summary
# silhouette matrix (including cluster & dissimilarity)
silh_mtrx = silh_km$silhouette_matrix
# global average silhouette
glob_avg = silh_km$silhouette_global_average
Run the code above in your browser using DataLab