Six points on a line are 1, 2, 3, 10, 11 and 12. Using a flat kernel of radius 2.5 (all points within distance 2.5 get equal weight), run mean shift by hand from the starting positions and . Where does each run stop, and what do you learn about the number of clusters?
Unsupervised learning, Mean shift
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can run the mean-shift iteration mean of neighbours and see that it climbs to density modes without being told .
Key idea
Mean shift moves a point to the mean of the data inside its window: . With a flat kernel this is the plain average of the points within the radius. The shift always points uphill on the kernel density estimate, so the runs stop at its modes.
Steps
- Set up: the data are 1, 2, 3, 10, 11, 12. With a flat kernel, a point is in the window if its distance from is at most 2.5.
- Start at . Points within 2.5 are those in , namely 2 and 3. Their mean is . New position: .
- From the window is and contains 1, 2, 3. Their mean is . New position: .
- From the window is and again contains 1, 2, 3. The mean is , so the shift is zero. The run has converged at the mode .
- Start at . The window contains 10 and 11, mean . From the window contains 10, 11, 12, mean . From the window contains 10, 11, 12 again, mean . It converges at .
- Every start near 1–3 ends at 2 and every start near 10–12 ends at 11. So there are two modes and two clusters. Points are labelled by the mode they reach, and was never supplied. The radius (bandwidth) controls how many modes appear.
Common mistakes
- Including points that lie exactly outside the radius, or leaving out points exactly on the boundary. Check each distance against 2.5.
- Thinking mean shift needs the number of clusters. It needs a bandwidth instead, and a small bandwidth gives many modes.
- Stopping after one step. Mean shift is an iteration and stops only when the shift is (almost) zero.
- Believing the window mean equals the nearest data point. The positions 2.5 and 10.5 are not data points.
How long your answer should be
Half a page with the sequence of positions; 3–4 minutes.
Last checked on 4 December 2026.
Read this
Previous in Unsupervised learning: Five shopping baskets are T1 = {A, B, C}, T2 = {A, B}, T3 = {A, C}, T4 = {B, C, D} and T5 = {A, B, C, D}. Run Apriori with minimum support count 2 to list all frequent itemsets. Then, for the rules and , compute confidence and lift. Which rule shows a real association?
Next in Unsupervised learning: How do you derive PCA as finding the direction of maximum variance?