Skip to content

Instantly share code, notes, and snippets.

@Navjotbians
Last active May 22, 2021 20:21
Show Gist options
  • Save Navjotbians/7b4fcfd5cc2ddf751ed30e1558164af8 to your computer and use it in GitHub Desktop.
Save Navjotbians/7b4fcfd5cc2ddf751ed30e1558164af8 to your computer and use it in GitHub Desktop.
Jaccard Score
def j_score(y_true, y_pred):
jaccard = np.minimum(y_true, y_pred).sum(axis = 1)/np.maximum(y_true, y_pred).sum(axis = 1)
return jaccard.mean()*100
def print_score(y_pred, y_test, clf):
print("Clf: ",clf.__class__.__name__)
print("Jaccard score: {}".format(j_score(pd.DataFrame(y_test), pd.DataFrame(y_pred))))
print("F1 Score : {}".format(f1_score(y_test, y_pred,average='macro')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment