Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
Function CosineSimilarity(v1, v2)
Dim numer As Integer
Dim denom1 As Double, denom2 As Double
'v1 and v2 are the vectors of the counts of keywords
numer = 0
denom1 = 0
denom2 = 0
For i = 1 To N 'N is the size of the vector
numer = numer + v1[i]*v2[i]
denom1 = denom1 + v1[i]*v1[i]
denom2 = denom2 + v2[i]*v2[i]
Next
CosineSimilarity = 1 - number/(sqrt(denom1)*sqrt(denom2))
End Function
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.