def jaccard_coefficient(X, Y):
 if (X is Y):
  X = Y = np.asanyarray(X)
 else:
  X = np.asanyarray(X)
  Y = np.asanyarray(Y)
 result = []
 i = 0
 for arrayX in X:
  result.append([])
  for arrayY in Y:
   n_XY = np.intersect1d(arrayY, arrayX).size
   result[i].append((n_XY / ((float(len(arrayX)) + len(arrayY)) - n_XY)))
  result[i] = np.array(result[i])
  i += 1
 return np.array(result)

def jaccard_coefficient ( X , Y ) : if ( X is Y ) : X = Y = np . asanyarray ( X ) else : X = np . asanyarray ( X ) Y = np . asanyarray ( Y ) result = [ ] i = 0 for arrayX in X : result . append ( [ ] ) for arrayY in Y : n_XY = np . intersect1d ( arrayY , arrayX ) . size result [ i ] . append ( ( n_XY / ( ( float ( len ( arrayX ) ) + len ( arrayY ) ) - n_XY ) ) ) result [ i ] = np . array ( result [ i ] ) i += 1 return np . array ( result )
compute the jaccard coefficient of all node pairs in ebunch .