initialize_clusters | R Documentation |
Initialize cluster memberships and component parameters to start the EM algorithm using a heuristic clustering method or user-defined labels.
initialize_clusters(
X,
G,
init_method = c("kmedoids", "kmeans", "hierarchical", "mclust", "manual"),
clusters = NULL
)
X |
An |
G |
The number of clusters, which must be at least 1. If |
init_method |
(optional) A string specifying the method to initialize
the EM algorithm. "kmedoids" clustering is used by default. Alternative
methods include "kmeans", "hierarchical", "manual". When
"manual" is chosen, a vector |
clusters |
A numeric vector of length |
Available heuristic methods include k-medoids clustering, k-means clustering,
and hierarchical clustering. Alternately, the user can also enter pre-specified
cluster memberships, making other initialization methods possible. If the given
data set contains missing values, only observations with complete records will
be used to initialize clusters. However, in this case, except when G = 1
, the resulting cluster
memberships will be set to NULL
since they represent those complete records
rather than the original data set as a whole.
A list with the following slots:
pi |
Component mixing proportions. |
mu |
A |
Sigma |
A |
clusters |
An numeric vector with values from 1 to |
Everitt, B., Landau, S., Leese, M., and Stahl, D. (2011). Cluster Analysis. John Wiley & Sons.
Kaufman, L. and Rousseeuw, P. J. (2009). Finding groups in data: an
introduction to cluster analysis, volume 344. John Wiley & Sons.
Hartigan, J. A. and Wong, M. A. (1979). Algorithm AS 136: A K-means clustering
algorithm. Applied Statistics, 28, 100-108. doi: 10.2307/2346830.
#++++ Initialization using a heuristic method ++++#
set.seed(1234)
init <- initialize_clusters(iris[1:4], G = 3)
init <- initialize_clusters(iris[1:4], G = 3, init_method = 'kmeans')
init <- initialize_clusters(iris[1:4], G = 3, init_method = 'hierarchical')
#++++ Initialization using user-defined labels ++++#
init <- initialize_clusters(iris[1:4], G = 3, init_method = 'manual',
clusters = as.numeric(iris$Species))
#++++ Initial parameters and pairwise scatterplot showing the mapping ++++#
init$pi
init$mu
init$Sigma
init$clusters
pairs(iris[1:4], col = init$clusters, pch = 16)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.