function to calculate the cosine distance and the cosine similarity.
The cosine distance between 2 vectors A and B is :

So 1-CosineSimilarity
And the cosine similarity is :

In simple terms :
- the cosine of the angle between the 2 vectors
- or , the dot product of the vectors divided by their magnitudes multiplied
Here is the simplest explanation (although his cos(45) is wrong) :