Glossary · Machine learning

Cosine similarity

Also called cosine, cosine distance, similarity matrix, fingerprint

A measure of how alike two lists of numbers are in pattern, ignoring their size: 1 for the same direction, 0 for unrelated, −1 for opposite.

Think of a list of nn numbers as an arrow in nn-dimensional space. Two arrows can be long or short, but the angle θ\theta between them says whether they point the same way. Cosine similarity is the cosine of that angle:

cos⁡θ=∑iaibi∑iai2 ∑ibi2\cos\theta = \frac{\sum_i a_i b_i}{\sqrt{\sum_i a_i^2}\,\sqrt{\sum_i b_i^2}}

It is 1 when one list is a scaled copy of the other, 0 when they share no pattern, and −1 when one is the other turned upside down. Because the lengths divide out, a loud and a quiet version of the same pattern score 1.

In this project

In the torque and neuron post each push and technique is a list of 512 numbers: every second-layer neuron’s mean response over the second after it. Each list is scaled to length 1 and the average of all of them is taken away first, so that what is compared is what makes a move different. Pushed from behind and from the left: 0.93. A cross and a rear hook: 0.75. A rear hook and a left high kick: −0.37.

Related terms

Used in

← All terms