Created
December 20, 2022 18:02
-
-
Save piercelamb/026ee0a4d7be375cc7966dc771ad9d67 to your computer and use it in GitHub Desktop.
get_multi_class_statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_multi_class_stats(statistics_counts, predicted_label_id, actual_label_id, id2label): | |
actual_label = id2label[actual_label_id] | |
statistics_counts[actual_label]['total'] += 1 | |
predicted_label = id2label[predicted_label_id] | |
if predicted_label == actual_label: | |
statistics_counts[actual_label]['true_positives'] += 1 | |
else: | |
# wrong prediction, the prediction is thus a false positive | |
# and the actual label is a false negative | |
statistics_counts[predicted_label]['false_positives'] += 1 | |
statistics_counts[actual_label]['false_negatives'] += 1 | |
return statistics_counts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment