Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. TP = 0.0
  2. FP = 0.0
  3. FN = 0.0
  4. TN = 0.0
  5.  
  6. N = len(clusters)
  7.  
  8. for i in range(N):
  9. for j in range(N):
  10. if i == j:
  11. continue
  12.  
  13. if clusters[i] == clusters[j] and labels[i] == labels[j]:
  14. TP += 1
  15. if clusters[i] == clusters[j] and labels[i] != labels[j]:
  16. FP += 1
  17. if clusters[i] != clusters[j] and labels[i] == labels[j]:
  18. FN += 1
  19. if clusters[i] != clusters[j] and labels[i] != labels[j]:
  20. TN += 1
  21.  
  22. return (TP + TN) / (TP + FP + FN + TN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement