Impementation of weighted cosine similarity