Advertisement
Danila_lipatov

Untitled

May 17th, 2024 (edited)
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. from sklearn.metrics import auc
  2. total = len(dat[target])
  3. one_count = np.sum(dat[target])
  4. one_count
  5. 33
  6. zero_count = total - one_count
  7. zero_count
  8. 766
  9. lm = [y for _,y in sorted(zip(dat[i],dat[target]),reverse=True)]
  10. x = np.arange(0,total+1)
  11. y = np.append([0],np.cumsum(lm))
  12. a = auc([0,total],[0,one_count])
  13. aP = auc([0,one_count,total],[0,one_count,one_count]) - a
  14. aR = auc(x,y) - a
  15. fpr, tpr, thresholds = roc_curve(target, var)
  16. auc_ = auc(fpr, tpr)
  17. ar = auc_ * 2 - 1
  18. print("Acc ratio:",aR/aP)
  19. print("Acc ratio from ROC curve:",2*roc_auc_score(dat[target],dat[i])-1)
  20. print("Acc ratio from ROC curve:",ar)
  21. Acc ratio: 0.9278423925943509
  22. Acc ratio from ROC curve: 0.775733839702508
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement