Skip to content
Discussion options

You must be logged in to vote

with 1.4 version it seems to be correct:

import torch
from torchmetrics.functional import precision as tm_precision
from sklearn.metrics import precision_score as sklearn_precision

preds = torch.tensor([0, 0, 1, 0, 0], dtype=torch.int)
target = torch.tensor([0, 0, 1, 1, 1], dtype=torch.int)
print("TM: ", tm_precision(preds=preds, target=target, task="binary"))
print("SK: ", sklearn_precision(y_true=target, y_pred=preds))

preds = torch.tensor([0, 0, 1, 0, 0], dtype=torch.float)
target = torch.tensor([0, 0, 1, 1, 1], dtype=torch.int)
print("TM: ", tm_precision(preds=preds, target=target, task="binary"))
print("SK: ", sklearn_precision(y_true=target, y_pred=preds))

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants