Skip to content
BI & Data ScienceClustering: finding groups without labels

Formulas for this chapter

Euclidean distance

D(X1, X2) = sqrt( (x11 - x21)^2 + (x12 - x22)^2 + ... + (x1n - x2n)^2 ) For assignment, compare the squared value and skip the root.

Any continuous-scale similarity: k-means assignment, KNN, load-distance. Standardise the columns first or the widest one decides the answer.

x1j, x2j
Value of variable j for observations 1 and 2
n
Number of variables

Standardising a column

z = (x - mean) / standard deviation (z-score) or x' = (x - min) / (max - min) (min-max, range 0 to 1)

Before any distance-based method. z-scoring in Excel is =(x - AVERAGE(col)) / STDEV.S(col); in R it is scale(data).

mean, standard deviation
Computed down the column, not across the row
min, max
Smallest and largest values in the column

Centroid and WCSS

centroid_j = mean of variable j over the cluster's members WCSS = SUM over clusters SUM over members ( distance to own centroid )^2

The update step of k-means, and the elbow plot. WCSS falls monotonically in k and is zero at k = n, so read the bend rather than minimising it.

centroid_j
The cluster's mean on variable j
k
Number of clusters, fixed before k-means runs
Step 3 of 26
The real wordsTheory

The four families

Centroid-basedGroups by distance from a central point, the centroid. k-means.
Connectivity-basedGroups by how close observations are to each other. Hierarchical clustering.
Distribution-basedGroups by the probability that observations come from the same distribution.
Density-basedSeparates high-density areas from low-density ones.

The course uses the first two, and names k-means and hierarchical as the popular algorithms.