def _cosine ( a , b ) : return 1. * len ( a & b ) / ( math . sqrt ( len ( a ) ) * math . sqrt ( len ( b ) ) )
get cosine of two numbers, python
Return the len ( a & b ) / len ( a )
def _cosine(a, b):
    """ Return the len(a & b) / len(a) """
    return 1. * len(a & b) / (math.sqrt(len(a)) * math.sqrt(len(b)))