def jaccard_similarity_score(y_true, y_pred, normalize=True, sample_weight=None):
 (y_type, y_true, y_pred) = _check_targets(y_true, y_pred)
 if y_type.startswith('multilabel'):
  with np.errstate(divide='ignore', invalid='ignore'):
   pred_or_true = count_nonzero((y_true + y_pred), axis=1)
   pred_and_true = count_nonzero(y_true.multiply(y_pred), axis=1)
   score = (pred_and_true / pred_or_true)
   score[(pred_or_true == 0.0)] = 1.0
 else:
  score = (y_true == y_pred)
 return _weighted_sum(score, sample_weight, normalize)

def jaccard_similarity_score ( y_true , y_pred , normalize = True , sample_weight = None ) : ( y_type , y_true , y_pred ) = _check_targets ( y_true , y_pred ) if y_type . startswith ( 'multilabel' ) : with np . errstate ( divide = 'ignore' , invalid = 'ignore' ) : pred_or_true = count_nonzero ( ( y_true + y_pred ) , axis = 1 ) pred_and_true = count_nonzero ( y_true . multiply ( y_pred ) , axis = 1 ) score = ( pred_and_true / pred_or_true ) score [ ( pred_or_true == 0.0 ) ] = 1.0 else : score = ( y_true == y_pred ) return _weighted_sum ( score , sample_weight , normalize )
jaccard similarity coefficient score the jaccard index [1] .