-
-
Save tengpeng/c5ee4de4cd8891bb5c55 to your computer and use it in GitHub Desktop.
backup m1
This file contains hidden or 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 mf(y_true, y_pred): | |
tp = 0 | |
fp = 0 | |
fn = 0 | |
for i in range(y_true.shape[0]): | |
for j in range(y_true.shape[1]): | |
if y_true[i, j] == y_pred[i, j]: | |
if y_true[i,j] == 1: | |
tp += 1 | |
elif y_true[i, j] != y_pred[i, j]: | |
if y_pred[i,j] == 1: | |
fp += 1 | |
else: | |
fn += 1 | |
p = tp/(tp + fp + 0.0001) | |
r = tp/(tp + fn + 0.0001) | |
f = 2*(p*r)/(p + r + 0.0001) | |
return f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment