Introduction to Mean Shift Algorithm
saravananthirumuruganathan.wordpress.com
saravananthirumuruganathan.wordpress.com
Basically, it goes like this:
1. Select a data point of interest.
2. Draw a circle of a specified radius around the point of interest.
3. Collect all data points within the circle and compute their mean.
4. Move the center of the circle to the mean.
5. Repeat 3 & 4 until convergence. Each iteration will move "uphill" on the density gradient of the data distribution until it reaches the top of the hill (a local maximum).
6. Repeat 1-5 for all data points. Points that converge to the same local maximum are members of the same cluster. The number of clusters is the number of local maxima.
For higher dimensions, replace "circle" with sphere (3-D) or hypersphere (4 & higher dimensions). Obviously, this algorithm depends on a choice of radius, which determines the granularity of the search for local maxima.
Couldn't you have a situation where points really far from a cluster would still converge to that cluster by this method? Something like a long string of points slowly getting closer and closer?
Does the mean shift algorithm have any guarantees on running time and/or the quality of the clustering it finds?
I don't think you have to run it on every point in the data set. If your data set is very large, you could run it on a random sample of points, or a define a regular grid of starting positions at the resolution that you require.
> Couldn't you have a situation where points really far from a cluster would still converge to that cluster by this method? Something like a long string of points slowly getting closer and closer?
Yes, that's the idea. For each point, you're basically asking "If I start here and keep walking up the density gradient from here until I hit a maximum, where do I end up?" If the shape of the probability density function has a very long ridge, you could end up walking the entire length of the ridge until you hit the highest point. This means that you can have arbitrary-shaped clusters, within the smoothness bounds imposed by your chosen radius. This feature is considered a potential advantage over k-means clustering, which can only produce convex clusters.
> Does the mean shift algorithm have any guarantees on running time and/or the quality of the clustering it finds?
I haven't actually used it in practice, so I don't know.
> does not assume anything about number of clusters
> can handle arbitrarily shaped clusters
> is fairly robust to initializations
> not very sensitive to outliers
> time complexity mean-shift: O(Tn^2), k-means: O(knT). (k: number of clusters, n: number of points, T: number of iterations).
[Edit: formatting]
This makes no sense. A clearer explanation would go a long way.
Better?
Given an estimate of the mean; for each data point, Mean shift defines a window around it and computes a new estimated mean weighting each point by the probability density at the previous estimated mean calculated using the window
The (weighted) 'mean of the data points within the window' makes sense if you use the other perspective of looking at the window around the current estimated mean - you'll get the same answer, and to me this explanation is easier to grasp - the PDF only depends on the distance between the point and the estimated mean so you can think of either as the 'center'. But saying you calculate the mean of the data points within the window for each data point mixes up two perspectives and makes no sense.
Suppose we had 500 data points. Daveguy's process calculates a separate mean for a window around each data point. Now we have 500 means...and?
At the high level, we can specify Mean Shift as follows : 1. Fix a window around each data point. 2. Compute the mean of data within the window. 3. Shift the window to the mean and repeat till convergence.
It seems to be a gradient ascent on a smoothed density function, so there's only a maximization step, no expectation step is involved.
any chance you could move it to github?
Here is a link to mean shift for sklearn: http://scikit-learn.org/stable/modules/generated/sklearn.clu...