View source: R/nugget-clustering.R
| Wkmeans | R Documentation |
k-means in which each observation carries a non-negative weight. Cluster
centres are weighted means and the objective is the Weighted Within-Cluster
Sum of Squares \sum_c \sum_{i \in c} w_i \lVert x_i - \mu_c \rVert^2.
Wkmeans(x, k, weights = rep(1, nrow(x)), nstart = 10, max_iter = 100)
x |
Numeric matrix, observations in rows. |
k |
Number of clusters. |
weights |
Non-negative weight per observation (default all 1). |
nstart |
Number of random restarts (best WWCSS kept). |
max_iter |
Maximum Lloyd iterations per start. |
A list with cluster, centers and wwcss.
Dey, T., Duan, Y., Cabrera, J. & Cheng, X. (2025). WCluster: Clustering and PCA with Weights, and Data Nuggets Clustering.
nugget_cluster, Whclust
set.seed(1)
x <- rbind(matrix(rnorm(20 * 3, 0), 20), matrix(rnorm(20 * 3, 5), 20))
Wkmeans(x, k = 2, weights = runif(40, 1, 5))$cluster[1:5]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.