Learning Outcome Statement
Describe unsupervised machine learning algorithms-including principal components analysis, k-means clustering, and hierarchical clustering-and determine the problems for which they are best suited.
On the exam: The vignette gives the data structure, objective, scaling, eigenvalues, centroids, or dendrogram, then asks for the best algorithm, an interpretation, or a variance or squared-distance result in an item set or multiple-choice question.
Unsupervised learning starts with observations but no target label. You want either a smaller coordinate set or a set of groups. When a grouping method needs a preselected number of groups, call that number $k$. The exam rewards matching the requested output to the algorithm.
| Algorithm | Data or objective | Result |
|---|---|---|
| PCA | Correlated variables, reduce dimensions | Orthogonal components, variance ranking |
| K-means | Compact groups, $k$ known | Labels, centroids |
| Hierarchical clustering | Nested or exploratory groups | Dendrogram, nested clusters |
Standardize the indicators before PCA when their scales differ, so scale does not dominate the variance. The retained scores can supply cleaner coordinates for a later clustering step, but clustering creates the group membership.
PCA transforms correlated variables into orthogonal components and ranks them by variance explained. For component $i$, let $\lambda_i$ be its eigenvalue. Let $v_i$ be its variance share, and let $j$ index every component in the data. Variance explained by component $i$ is calculated as follows.
$$ v_i=\frac{\lambda_i}{\sum_j \lambda_j} $$
The numerator carries the variance of the chosen component. The denominator adds the variance carried by every component. A larger $\lambda_i$ raises $v_i$, while a larger denominator lowers $v_i$ when the numerator stays fixed.
The model choice is a decision about the output you need. Standardize indicators first, then follow the branch that matches reduction, centroid assignment, or nested grouping.
Loading diagram…
K-means assigns observations to the nearest centroid and updates centroids iteratively. A centroid is the current center of a group in the score space. It suits compact groups when $k$ is known. Hierarchical clustering builds nested groups that can be inspected through a dendrogram. The dendrogram lets you inspect nested relationships before selecting a grouping cut.
Worked example
You are handed cross-sectional data on funds with three standardized risk indicators. PCA returns three components with eigenvalues, and the analyst keeps two components before assigning a new fund to the nearer of two candidate centroids. The exam asks for the variance retained and the nearer centroid.
| Item | Value |
|---|---|
| Standardized indicators | 3 |
| PCA components | 3 |
| Components retained | 2 |
| Candidate clusters | 2 |
| Eigenvalues $(\lambda_1,\lambda_2,\lambda_3)$ | $2.1, 0.6, 0.3$ |
| New fund $(PC_1, PC_2)$ | $1.2, 0.4$ |
| Growth centroid | $1.8, 0.7$ |
| Defensive centroid | $-0.6, -0.3$ |
These are cross-sectional observations, so no annual or periodic conversion applies. The indicators were standardized before PCA, and the supplied eigenvalues are dimensionless outputs from a sample analysis. The negative scores are coordinates, not cash-flow signs.
The bars are the eigenvalues in component order.
Loading diagram…
For the distance calculation, the new fund's first score is $x_1=1.2$ and its second score is $x_2=0.4$. The growth centroid has coordinates $g_1=1.8$ and $g_2=0.7$. The defensive centroid has coordinates $r_1=-0.6$ and $r_2=-0.3$. For a centroid with coordinates $c_1$ and $c_2$, the squared Euclidean distance $d^2$ is calculated as follows.
$$ d^2=(x_1-c_1)^2+(x_2-c_2)^2 $$
- Add the eigenvalues because the denominator is total variance. This produces $\lambda_1+\lambda_2+\lambda_3=2.1+0.6+0.3=3.0000$.
- Divide the first eigenvalue by total variance. This produces $v_1=\frac{2.1}{3.0000}=0.70$, or 70.00%.
- Calculate the remaining shares because retained variance includes the other component. The shares are $\frac{0.6}{3.0000}=0.20$ and $\frac{0.3}{3.0000}=0.10$. The retained cumulative share is $0.70+0.20=0.90$, or 90.00%.
- Compare the fund with the growth centroid by squaring each coordinate difference and adding them. The differences are $-0.60$ and $-0.30$, giving $0.36+0.09=0.45$.
- Repeat the distance calculation for the defensive centroid. The differences are $1.80$ and $0.70$, giving $3.24+0.49=3.73$.
Keeping two components retains 90.00% of variance. The new fund is closer to growth because 0.45 is less than 3.73, so K-means assigns it to growth.
Changed condition
| Quantity | Original | Changed |
|---|---|---|
| $PC_1$ eigenvalue | 2.1 | 1.8 |
| Total eigenvalue sum | 3.0000 | 2.7000 |
| $PC_1$ variance share | 0.70 | 0.67 |
| Two-component cumulative share | 0.90 | 0.89 |
Predict the direction before calculating. Lowering the $PC_1$ eigenvalue lowers its numerator and the denominator, so the share falls from 0.70 to 0.67. The two-component cumulative share falls from 0.90 to 0.89, while the centroid distances do not move because the scores and centroids are unchanged. Now calculate the changed $PC_2$ share yourself.
Common error
You may reach for PCA because it reduces dimensions and makes observations easier to plot. That choice feels right when you want a simpler picture, but PCA creates new coordinates rather than groups. When the question asks you for labels, segments, centroids, or a dendrogram, choose clustering because the clustering algorithm assigns observations to groups.
Calculator
Use the squared growth distance to check the nearest-centroid calculation.
| Keys | Display |
|---|---|
| 0.36 | 0.36 |
| + | 0.36 |
| 0.09 | 0.09 |
| = | 0.45 |
Check yourself
Practice
A cross-sectional fund study standardizes three risk indicators. PCA produces eigenvalues 2.1, 0.6, and 0.3. The new fund scores 1.2 and 0.4 on PC_1 and PC_2. Candidate centroids are growth at 1.8 and 0.7 and defensive at -0.6 and -0.3. The analyst uses two components and squared Euclidean distance.
Question 1
Which algorithm is best suited to transform correlated indicators into fewer orthogonal coordinates?
Question 2
What proportion of variance does PC_1 explain?
Question 3
Using squared Euclidean distance, what is the new fund's distance squared to the growth centroid?
Question 4
Which algorithm assigns the new fund to the nearest candidate centroid?
An analyst wants nested or exploratory groups and wants to inspect the structure through a dendrogram. Which algorithm is best suited?
Revision snapshot
PCA transforms correlated variables into orthogonal components and ranks them by variance explained. Variance explained by a component equals its eigenvalue divided by the sum of all eigenvalues. Use $v_i=\frac{\lambda_i}{\sum_j\lambda_j}$. K-means assigns observations to the nearest centroid and updates centroids iteratively. Hierarchical clustering builds nested groups that can be inspected through a dendrogram. The trap is treating PCA coordinates as group labels.
| Method | Choose it for |
|---|---|
| PCA | Reduction |
| K-means | Compact groups, $k$ known |
| Hierarchical clustering | Nested or exploratory grouping |
Choose PCA for reduction, k-means for compact groups when $k$ is known, and hierarchical clustering for nested or exploratory grouping. On the exam, match the requested output to the method.
Unlock the full lesson and continue reading
Signup to continue reading this lesson and unlimited access questions, flashcards, AI notes, and more