The cosine similarity is a calculation used in data mining. As far as I’m aware, this is the first and only online cosine similarity calculator. Sweet. Enjoy! :)

**Explanation**

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.

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))).

**Directions**

This is a Cosine Similarity Calculator. There is currently little data validation so make sure your vectors are of **equal length**, are **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:

**Calculator**

Your calculations will appear hear after you push the Calculate button!