Still, k-means is enormously practical despite its shortcomings.
Still, k-means is enormously practical despite its shortcomings.
K-means in its standard form does make a Euclidean hypothesis (it does not minimize a distance but the in-cluster variance).
It is not correct to use arbitrary distances because k-means may stop converging with other distance functions.
See this thread for more info: https://stats.stackexchange.com/questions/81481/why-does-k-m...
The distance function can be anything.
You shuffle your big ass wad of data, and loop over each element doing the above, optionally decreasing the forgetting rate.
You track the location of your centroids and if your data / loss fn isn't too pathological, they won't misbehave too badly and you have handwavey assurance of convergence... Definitions be damned.
https://en.m.wikipedia.org/wiki/K-medoids
This is especially useful in cases where the distance between points is given by a matrix, and cannot be derived from the points themselves. For example, the drive time between locations on a road network.
distance <- sqrt(d_price*2 + d_area*2)
Without normalizing the units somehow, so that they have a meaningfully similar numeric expression, you are essentially only clustering by price, which is in the tens- or hundreds-of-thousands.You use very little information about the area, because that is in the hundreds, at most thousands.
The point I was making was that the different scale of the features influences the result by a lot.
K-means minimizes within-cluster variance. If you look at the definition of variance, it is identical to the sum of squared Euclidean distances from the centroid