clust2params: Converts Hard Assignment Into Cluster Parameters

View source: R/clust2params.R

clust2paramsR Documentation

Converts Hard Assignment Into Cluster Parameters

Description

Transforms cluster labels into a list of parameters describing cluster size, mean, and dispersion.

Usage

clust2params(data, cluster)

Arguments

data

a numeric vector, matrix, or data frame of observations. Rows correspond to observations and columns correspond to variables/features. Categorical variables and NA values are not allowed.

cluster

a vector of integers representing cluster labels. Labels need not be consecutive.

Value

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.

Examples

# 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


qcluster documentation built on June 5, 2026, 5:07 p.m.