Skip to content

Instantly share code, notes, and snippets.

@therealnaveenkamal
Created July 22, 2021 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealnaveenkamal/1371116550b2165d29c6f4684a32057e to your computer and use it in GitHub Desktop.
Save therealnaveenkamal/1371116550b2165d29c6f4684a32057e to your computer and use it in GitHub Desktop.
This code is the gives the AUC score of each and every class of the Chest X-Ray
auc_vals = []
for i in range(len(labels)):
try:
gt = np.array(testgenerator.labels[:, i])
pred = predicted_vals[:,i]
gt = gt.astype('int64')
auc_vals.append(roc_auc_score(gt, pred))
fpr_rf, tpr_rf, _ = roc_curve(gt, pred)
plt.figure(1, figsize=(10, 10))
plt.plot([0, 1], [0, 1], 'k--')
plt.plot(fpr_rf, tpr_rf, label=labels[i] + " (" + str(round(auc_roc, 3)) + ")")
plt.xlabel('False positive rate')
plt.ylabel('True positive rate')
plt.title('ROC curve')
plt.legend(loc='best')
except ValueError:
pass
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment