How to calculate cosine similarity between scalar and vector in Python?
I am trying to multiply the output of a ngram model's probability with the output of a pretrained word2vec model to rerank the next possible word using word prediction. (Natural language processing)
Is there a library for this? I tried sklearn's here:https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.cosine_similarity.html
But it only takes in two vectors to calculate pairwise cosine similarity.
The cosine similarity is, by definition, a measure of similarity between two vectors (see Wikipedia entry). If you imagine the two vectors in an Euclidean space, it measures how aligned their orientations are. Therefore the cosine similarity between a vector and a scalar is not defined.
What exactly do you want to measure?