Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Only computes a batch-wise average of recall.
  2.  
  3. Computes the recall, a metric for multi-label classification of
  4. how many relevant items are selected.
  5. """
  6. true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
  7. possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))
  8. recall = true_positives / (possible_positives + K.epsilon())
  9. return recall
  10.  
  11. def precision(y_true, y_pred):
  12. """Precision metric.
  13.  
  14. Only computes a batch-wise average of precision.
  15.  
  16. Computes the precision, a metric for multi-label classification of
  17. how many selected items are relevant.
  18. """
  19. true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
  20. predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))
  21. precision = true_positives / (predicted_positives + K.epsilon())
  22. return precision
  23. precision = precision(y_true, y_pred)
  24. recall = recall(y_true, y_pred)
  25. return 2*((precision*recall)/(precision+recall+K.epsilon()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement