Fixing a bug to check mistakes against test/train set, and add the code to compute the cosine similarity