#NEWLINE# def cosine_distance( u , v ) : #NEWLINE# #INDENT# '\n    Returns 1 minus the cosine of the angle between vectors v and u. This is equal to\n    1 - (u.v / |u||v|).\n    ' #NEWLINE# return ( 1 - ( numpy . dot ( u , v ) / ( sqrt ( numpy . dot ( v , u ) ) * sqrt ( numpy . dot ( v , v ) ) ) ) )