Groups without labels
Clustering looks for groups of similar rows without being told what the groups are. K-means is the workhorse. Pick centres, then repeat two steps: assign each point to its nearest centre, and move each centre to the mean of its points. It stops when nothing changes. The quantity it lowers is the inertia, the sum of squared distances from each point to its centre. Because k-means uses distances, features must be on a common scale, and because it always finds groups, it will find them even in data that has none. In finance clustering is used to label regimes (calm, stormy, crisis) and to find peers, stocks that behave alike.
How good is a clustering? The silhouette of a point compares , its mean distance to the other points of its own cluster, with , its mean distance to the points of the nearest other cluster: . It is near for a point deep inside a tight, well separated cluster, near on a border and negative if the point is probably in the wrong cluster. The mean silhouette helps to compare values of , but it never proves that clusters are real. Always re-run with other starting points and other features, and ask whether the groups mean something for trading.
- Two steps: assign to the nearest centre, move the centre to the mean, repeat.
- Scale first: distances treat every feature alike, so a large-unit feature would dominate.
- Clusters are a lens, not a fact: check stability and meaning before you trade on them.
Lab · what's graded
- A new centre10 pts
- The inertia10 pts
- Distance inside the cluster10 pts
- A silhouette15 pts
- Days that are not calm5 pts
- Why scale the features10 pts
- The steps of k-means10 pts
- Match the vocabulary10 pts
- Why clusters need checking20 pts