0
$\begingroup$

I'm learning about the K-means model. I'm going to detect the anomalies using the k-means for that I need to calculate the distance between centers and point how should I do that.

$\endgroup$
  • $\begingroup$ By pythagorean theorem, if your input are the coordinates of data points plus of the centres. $\endgroup$ – ttnphns Aug 8 '17 at 11:47
  • $\begingroup$ sorry, I didn't get it $\endgroup$ – Newbie Aug 8 '17 at 11:50
  • $\begingroup$ (L2) norm(x-m) where m is the centre and x is the point. But this doesn't necessarily pick out real anomalies. For some clusters points 'far away' from the centre could be perfectly normal. You may do better using GMM and allowing each cluster its own covariance matrix. $\endgroup$ – conjectures Aug 8 '17 at 11:55
0
$\begingroup$

You can just compute the Euclidean distance of any points within one cluster with respect to that cluster's centroid. For categorical variable, it is preferable to use distance as either 1 or 0 (means if 2 observations of same features are having same class then take distance for that feature as 1,else 0). To get the K-means cluster(assuming that you are using some language for clustering), K-means generally have a attribute like "cluster_centers_" (available in python)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.