Home Products Support Blog Forum




Cosine Similarity Calculator


This Cosine Similarity Calculator will teach you how to calculate the Cosine Similarity (a.k.a. how to calculate the Cosine Measure) of two vectors. Useful for both math homework and data mining. Please add your favorite store or restaurant to Poipedia.org if this calculator helps you. :) Thanks!

The Cosine Similarity of two vectors is an arbitrary mathematical measure of how similar two vectors are on a scale of [0, 1]. 1 being that the vectors are either identical, or that their values differ by a constant factor.

The Cosine Similarity of two vectors (d1 and d2) is defined as:
cos( d1, d2 ) =  dot(d1,d2) / ||d1|| ||d2||

Where dot(d1,d2) = d1[0]*d2[0] + d1[1]*d2[1] ...
And Where ||d1|| = sqrt(d1[0]^2 + d1[1]^2 ...)

(Additional Info For Data Miners:  The Centroid Similarity Measure is 
simply the Cosine Measure of your clustering output.  e.g. After clustering 
some data, if you only have two centroids, to get the Centroid Similarity 
Measure, you just take the Cosine Measure of the resultant vectors.  If you 
have k centroids though such that k > 2 (and this formula works for k=2 as 
well), then it is the Summation From i=1 to K(Summation From j=1 to K 
(Cosine Similarity(Ci,Cj))).

This is a Cosine Similarity Calculator.  There is currently no data validation.  
Make sure your vectors are of equal length, numeric in type, and with each value 
separated by a single space.  For example ~> "1 2 3" (without the quote marks) 
would be a valid input:

Enter Vector 1 (Values Separated by Spaces)
Enter Vector 2 (Values Separated by Spaces)