余弦距离

def cosine_distant(vector1, vector2):
    """余弦距离"""
    vector1 = np.mat(vector1)
    vector2 = np.mat(vector2)
    vector1_norm = np.linalg.norm(vector1)
    vector2_norm = np.linalg.norm(vector2)
    dot_norm = vector1_norm * vector2_norm
    dot_vs = np.dot(vector1, vector2)
    return np.divide(dot_vs, dot_norm).item()