# 7.00.02 - Cosine Similarity - Aster Analytics

## Teradata Aster® Analytics Foundation User GuideUpdate 2

Product
Aster Analytics
Release Number
7.00.02
Release Date
September 2017
Content Type
Programming Reference
User Guide
Publication ID
B700-1022-700K
Language
English (United States)

The cosine similarity between two vectors of an inner product space is the cosine of the angle between them. The cosine of 0° is 1 and the cosine of any other angle is less than 1. Therefore, the cosine similarity measures orientation and not magnitude. Regardless of their magnitude, two vectors with the same orientation have a cosine similarity of 1, two vectors at 90° have a cosine similarity of 0, and two diametrically opposed vectors have a cosine similarity of -1.

Cosine similarity is not a true distance metric, because it does not have the triangle inequality property and it violates the coincidence axiom (which says that two things separated by zero distance must be identical).

Given two vectors of attributes, A and B, the cosine similarity, cos(θ), is represented using a dot product and magnitude as:

Cosine similarity is most commonly used in high-dimensional positive spaces. In positive space, cosine similarity is often used for the complement, that is:

D cos(A, B) = 1 - S cos(A, B)