Home Calculator Cosine Similarity Calculator

Cosine Similarity Calculator

30
0
Cosine Similarity Calculator

What is Cosine Similarity?

Cosine Similarity Calculator: Cosine similarity is a measure of similarity between two non-zero vectors in an inner product space. It is often used in text analysis and data mining to determine how similar two vectors are. The cosine similarity is calculated by finding the cosine of the angle between the vectors, and it ranges from -1 (completely dissimilar) to 1 (completely similar).

Vector a

Vector b

How to Use the Cosine Similarity Calculator

Enter the components of vectors a and b into the provided input fields. Click "Calculate" to get the cosine similarity, angle between vectors, and cosine distance. The results will be displayed in a table format along with a visual chart showing the similarity. Use the "Clear" button to reset all fields and results.

Formula for Cosine Similarity Calculator

The formula to calculate cosine similarity is:

SC(a, b) = (a · b) / (‖a‖ × ‖b‖)

Where:
a · b = a₁b₁ + a₂b₂ (Dot Product of a and b)
‖a‖ = √(a₁² + a₂²) (Magnitude of vector a)
‖b‖ = √(b₁² + b₂²) (Magnitude of vector b)

FAQs

What is Cosine Similarity used for?

Cosine similarity is used to measure the similarity between two vectors, often in text analysis or data mining. It helps determine how similar two items are based on their vector representations, regardless of their magnitude.

How is the angle between vectors calculated?

The angle between vectors is calculated using the cosine similarity formula. Once the cosine similarity is obtained, the angle can be derived using the inverse cosine function (arccos) of the similarity value.

What does cosine distance represent?

Cosine distance is a measure of dissimilarity between two vectors. It is calculated as 1 minus the cosine similarity. A value closer to 1 indicates greater dissimilarity, while a value closer to 0 indicates more similarity.

Can cosine similarity be negative?

Yes, cosine similarity can be negative if the vectors are diametrically opposed, i.e., they point in opposite directions. This indicates that the vectors are dissimilar or have an angle greater than 90 degrees between them.

How do I interpret the cosine similarity value?

A cosine similarity value close to 1 means that the vectors are highly similar or nearly identical, while a value close to 0 indicates no similarity. A value close to -1 means the vectors are diametrically opposed, or highly dissimilar.

Related Calculator-