Skip to content
Discussion options

You must be logged in to vote

@ceceu after trying myself, I assume you have set the average argument in the first case to macro and in the second case to micro (default):

y = torch.tensor([0, 0, 2, 2, 1, 1, 1, 2, 0, 0])
y_hat = torch.tensor([1, 1, 2, 1, 1, 1, 1, 1, 2, 1])

precision = Precision(num_classes=3, average='macro')
recall = Recall(num_classes=3, average='macro')
print(precision(y_hat, y), recall(y_hat, y)) # tensor(0.2917), tensor(0.4444)

precision = Precision(num_classes=3, average='micro')
recall = Recall(num_classes=3, average='micro')
print(precision(y_hat, y), recall(y_hat, y)) # tensor(0.4000), tensor(0.4000)

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Borda
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #4967 on February 04, 2021 23:43.