# Cosine similarity is bad distance metric to use for kNN

Cosine distance is a term often used for the complement in positive space, that is: ${\displaystyle D_{C}(A,B)=1-S_{C}(A,B)} D_{C}(A,B)=1-S_{C}(A,B)$. It is important to note, however, that this is not a proper distance metric as it does not have the triangle inequality property and it violates the coincidence axiom; to repair the triangle inequality property while maintaining the same ordering, it is necessary to convert to angular distance (see below.) Wiki Reference

I like to get the intuition of how violating triangle inequality make it a bad metric.

• Violating the triangle inequality doesn't make it a bad distance metric - it makes it "not a proper distance metric" at all! By definition, a metric must satisfy the triangle inequality (in addition to a few others) en.wikipedia.org/wiki/Metric_(mathematics). Whether or not its good or bad depends on your use-case. – ilanman Oct 4 '16 at 23:31
• "Cosine distance" 1-cos is simply a squared euclidean distance (for unit-normalized vectors). Squared euclidean distance violates triangular ineqiality. See this thread stats.stackexchange.com/q/135171/3277 about "correlation distances" - almost everything said there is true for cosine similarity too. – ttnphns Oct 5 '16 at 0:52