torchmetrics icon indicating copy to clipboard operation
torchmetrics copied to clipboard

Support for 2D tensors for pearson and spearman correlations

Open DomInvivo opened this issue 1 year ago • 1 comments

Why constraint the pearson correlation to a single dimension? With a 2D tensor, the pearson correlation can be computed simultaneously for every column. Simply need to replace the .sum() and .mean() by .sum(0) and .mean(0) to compute the pearson per column. See code here: https://github.com/Lightning-AI/metrics/blob/de94064e2eb562f0a06f311382e12368e997a801/src/torchmetrics/functional/regression/pearson.py#L48

Then, we can provide a multioutput option like the r2_score, with the possibility of returning either the full score list, or the average of the scores.

Thank you!

DomInvivo avatar Aug 08 '22 16:08 DomInvivo

Hi! thanks for your contribution!, great first issue!

github-actions[bot] avatar Aug 08 '22 16:08 github-actions[bot]