Skip to content

Instantly share code, notes, and snippets.

@omarsar
Created October 15, 2018 09:16
Show Gist options
  • Save omarsar/090197c2be8799226cd42229e3ffcba1 to your computer and use it in GitHub Desktop.
Save omarsar/090197c2be8799226cd42229e3ffcba1 to your computer and use it in GitHub Desktop.
def numeric_score(prediction, groundtruth):
FP = np.float(np.sum((prediction == 1) & (groundtruth == 0)))
FN = np.float(np.sum((prediction == 0) & (groundtruth == 1)))
TP = np.float(np.sum((prediction == 1) & (groundtruth == 1)))
TN = np.float(np.sum((prediction == 0) & (groundtruth == 0)))
return FP, FN, TP, TN
def accuracy(prediction, groundtruth):
FP, FN, TP, TN = numeric_score(prediction, groundtruth)
N = FP + FN + TP + TN
accuracy = np.divide(TP + TN, N)
return accuracy * 100.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment