Distance Metrics¶
Euclidean distance¶
This is the geometrical distance you probably are familiar with in two dimensions. It works in any number of dimensions:
Manhattan distance¶
The Manhattan distance moves along grid lines. It penalizes strong differences in one dimension less than the Euclidean distance:
Cosine similarity¶
As an Euclidean similarity measure, cosine similarity is commonly used:
Or, in more detail:
Adjusted Cosine Similarity¶
Simple cosine similarity does not account for different rating scales. There might be happy raters who usually give higher ratings and pessimistic raters who generally give really low ratings.
To account for these differences we can normalize the rating data by substracting the users’ average from each rating:
It turns out that (for user-user similarities) this measure is similar to Pearson’s correlation that we frequently use in statistics.
Jaccard similarity¶
For binary variables you might use the Tanimoto coefficient (also see Jaccard Index). It uses the number of bits:
Or in simpler terms: