17.8 C
London
Sunday, June 22, 2025
HomeExcelDescriptive Statistics in ExcelHow to Calculate Cosine Similarity in Excel

How to Calculate Cosine Similarity in Excel

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

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:

=SUMPRODUCT(A$2:A$9,B2:B9)/(SQRT(SUMSQ(B2:B9))*SQRT(SUMSQ($A$2:$A$9)))

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 calculate Cosine Similarity in other statistical software:

For an in-depth explanation of Cosine Similarity, refer to the following Wikipedia article:

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories