torchmetrics
torchmetrics copied to clipboard
Support for 2D tensors for pearson and spearman correlations
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!
Hi! thanks for your contribution!, great first issue!