How to Calculate Cosine Similarity in Excel

Cosine Similarity is a measure of the similarity between two vectors of an inner product space.

For two vectors, A and B, the Cosine Similarity is calculated as:

Cosine Similarity = ΣAiBi / (√ΣAi2√ΣBi2)

This tutorial explains how to calculate the Cosine Similarity between vectors in Excel.

Cosine Similarity Between Two Vectors in Excel

Suppose we have the following two vectors in Excel:

We can use the following formula to calculate the Cosine Similarity between the two vectors in Excel:


The following screenshot shows how to use this formula:

cosine similarity formula in Excel

The Cosine Similarity between the two vectors turns out to be 0.965195.

Note that we interpret the value for Cosine Similarity as follows:

  • A value of -1 indicates maximum dissimilarity
  • A value of 0 indicates that the two vectors are orthogonal
  • A value of 1 indicates maximum similarity

A value of 0.965195 indicates a high level of similarity between the two vectors in our example.

Additional Resources

The following tutorials explain how to perform other common operations in Excel:

How to Calculate Manhattan Distance in Excel
How to Calculate Cross Correlation in Excel
How to Perform Fuzzy Matching in Excel

Leave a Reply

Your email address will not be published. Required fields are marked *