Commit ff048189 authored by pvskand's avatar pvskand
Browse files

added jaccard index metric

parent c88afda6
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ from sklearn.metrics import mean_absolute_error
from sklearn.metrics import precision_score
from sklearn.metrics import precision_recall_curve
from sklearn.metrics import auc
from sklearn.metrics import jaccard_similarity_score
from scipy.stats import pearsonr


@@ -71,6 +72,16 @@ def pearson_r2_score(y, y_pred):
  """Computes Pearson R^2 (square of Pearson correlation)."""
  return pearsonr(y, y_pred)[0]**2

def jaccard_index(y, y_pred):
  """Computes Jaccard Index which is the Intersection Over Union metric
     which is commonly used in image segmentation tasks

    Parameters
    ----------
    y: ground truth array
    y_pred: predicted array
  """
  return jaccard_similarity_score(y, y_pred)

def prc_auc_score(y, y_pred):
  """Compute area under precision-recall curve"""