| clust2params | R Documentation |
Transforms cluster labels into a list of parameters describing cluster size, mean, and dispersion.
clust2params(data, cluster)
data |
a numeric vector, matrix, or data frame of observations. Rows
correspond to observations and columns correspond to variables/features.
Categorical variables and |
cluster |
a vector of integers representing cluster labels. Labels need not be consecutive. |
A list containing cluster parameters, conformable with the Gaussian
parameterization used by functions such as qscore.
Let P=number of variables/features and
K=number of clusters. The elements of the list are as
follows:
proportion: a vector of clusters' proportions;
mean: a matrix of dimension (P x K) containing the
clusters' mean parameters;
cov: an array of size (P x P x K) containing the
clusters' covariance matrices.
# load data
data("banknote")
# compute the k-means partition
set.seed(2024)
cl <- kmeans(banknote[-1], centers = 2, nstart = 1)$cluster
# convert k-means hard assignment into cluster parameters
clpars <- clust2params(banknote[-1], cl)
clpars
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.