from numpy import dot
from numpy.linalg import norm


# cosine similarity between vectors
def cos(v1, v2):
    if norm(v1) > 0 and norm(v2) > 0:
        return dot(v1, v2) / (norm(v1) * norm(v2))
    else:
        return 0.0
