| compute_wss | R Documentation |
Compute Within-Cluster Sum of Squares
compute_wss(object, newdata = NULL)
object |
( |
newdata |
( |
WSS is defined as
\sum_{i=1}^{n} \left\|x_{i} - \mu_{j(i)}\right\|^2,
where x_{i} is a data point and \mu_{j(i)} is the centroid of the cluster
to which x_{i} is assigned. When new data is provided, the function predicts
the nearest cluster for each new observation and computes the WSS for these points
based on their predicted clusters.
A numeric() vector with one within-cluster sum of squares per cluster,
in the order of the rows of object$centers. Clusters with no assigned points
contribute 0.
km <- kmeans(mtcars, 5)
compute_wss(km)
# or with new data
compute_wss(km, mtcars)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.