Clustering
A typical interview question is: "How would you cluster 500 stocks from their returns, and how would you know the clusters are real?" A full answer states the objective and what the algorithm guarantees, picks a distance built from correlation, and treats stability under resampling as the test of whether a cluster exists.
k-means
k-means splits points into groups to minimise the within-cluster sum of squares:
where is the mean of cluster . Lloyd's algorithm alternates two steps: assign each point to its nearest centre, then move each centre to the mean of its points. Each step can only lower or leave it unchanged, and there are finitely many partitions, so the algorithm stops. It stops at a local minimum, not the global one, so run it from several starts and keep the lowest .
The rest of this lesson is for subscribers
Unlock every lesson in Machine Learning for Quantitative Research, and every other premium course.
Subscribe to continueTest your knowledge
Keep reading Machine Learning for Quantitative Research
27 lessons in this course, and every other premium course, on one subscription.
- Every lesson in every course, with the worked examples and interactive simulators
- Graded questions on every lesson, with explanations for the wrong answers as well as the right one
- The trainers, timed assessments and brainteaser library that go with them