Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. # Creating the Confusion Matrix
  2. from sklearn import metrics
  3. from sklearn.metrics import confusion_matrix
  4. from sklearn.metrics import roc_auc_score
  5. from sklearn.metrics import accuracy_score
  6. from sklearn.metrics import recall_score
  7. from sklearn.metrics import f1_score
  8. from sklearn.metrics import precision_score
  9. from sklearn.metrics import cohen_kappa_score
  10. from sklearn.metrics import balanced_accuracy_score
  11. import math
  12. cm = confusion_matrix(y_real, y_pred)
  13. print(cm)
  14. recall=recall_score(y_real, y_pred, average=None)
  15. Acc=accuracy_score(y_real, y_pred)
  16. Bacc=balanced_accuracy_score(y_real, y_pred)
  17. Kap=cohen_kappa_score(y_real, y_pred)
  18. AUC=roc_auc_score(y_real, y_pred)
  19. F1=f1_score(y_real, y_pred)
  20. GM=math.sqrt(recall[0]*recall[1])
  21. #mean = ค่าเฉลี่ยของ Accuracy AUC F1 GM
  22. mean=(Acc+AUC+F1+GM)/4
  23. print("Acc:{:.6f}||Bacc:{:.6f}||AUC:{:.6f}||Kap:{:.6f}||rec:{:.6f}||spec:{:.6f}||pre:{:.6f}||F1:{:.6f}||GM={:.6f}||Mean:{:.6f}".format(Acc,Bacc,AUC,Kap,recall[0],recall[1],precision_score(y_real, y_pred),F1,GM,mean))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement