def percentOverlap(x1, x2, size):
 nonZeroX1 = np.count_nonzero(x1)
 nonZeroX2 = np.count_nonzero(x2)
 minX1X2 = min(nonZeroX1, nonZeroX2)
 percentOverlap = 0
 if (minX1X2 > 0):
  percentOverlap = (float(np.dot(x1, x2)) / float(minX1X2))
 return percentOverlap

def percentOverlap ( x1 , x2 , size ) : nonZeroX1 = np . count_nonzero ( x1 ) nonZeroX2 = np . count_nonzero ( x2 ) minX1X2 = min ( nonZeroX1 , nonZeroX2 ) percentOverlap = 0 if ( minX1X2 > 0 ) : percentOverlap = ( float ( np . dot ( x1 , x2 ) ) / float ( minX1X2 ) ) return percentOverlap
computes the percentage of overlap between vectors x1 and x2 .