Last active
May 22, 2021 20:21
-
-
Save Navjotbians/7b4fcfd5cc2ddf751ed30e1558164af8 to your computer and use it in GitHub Desktop.
Jaccard Score
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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