pytorch / torcheval

A library that contains a rich collection of performant PyTorch model metrics, a simple interface to create new metrics, a toolkit to facilitate metric computation in distributed training and tools for PyTorch model evaluations.
https://pytorch.org/torcheval
Other
214 stars 46 forks source link

Mutliclass Precision Recall Curve, docs not consistent with execution #203

Open brynhayder opened 1 month ago

brynhayder commented 1 month ago

📚 The doc issue

Here the examples in the documentation shows that the output precisions and thresholds have the same length, but the recalls are one element longer

https://pytorch.org/torcheval/main/generated/torcheval.metrics.functional.multilabel_precision_recall_curve.html#torcheval.metrics.functional.multilabel_precision_recall_curve

However, in my execution the precisions and recalls are the same length (as expected) and the thresholds one element shorter.

Moreover, I see that the missing element in thresholds possibly comes from the use of diff to calculate, but shouldn't there be the same number of elements in each of the arrays output? Aren't P and R functions of threshold?

Suggest a potential alternative/fix

No response

brynhayder commented 1 month ago

Seems from here that you're appending values to the end of the precisions and recalls for graphical purposes, hence the discrepancy in number of elements I describe above. I didn't notice this anywhere in the documentation.

IMO, coming from the principle of least surprise, it would be better to remove this and leave it to the user to append these values if they want their charts to look a certain way.