torchmetrics
torchmetrics copied to clipboard
Add weights for the pearson, spearman, and r2_score
🚀 Feature
We can provide a weight Tensor to the regression coefficients, such as pearson, spearman, and r2_score
Motivation
It should be relatively simple to add weights to these computations. And it can be useful in many contexts, including masking by providing 0-weights, or adding more weights to the relevant sample/target pairs.
Pitch
Adding weights
parameter in pearson
, spearman
, and r2_score
. The parameter weights
should be either None
, 1D ,or 2D.
Alternatives
None
Additional context
See weighted pearsonr. For the spearmanr, it should be identical, since spearman is the correlation of the rank.
For the r2_score, there exist some implementations for example in sklearn, but it would be better to provide either a 1D or 2D matrix, and it would be broadcasted to the same shape as preds / target. instead of forcing sample_weight
to be 1D.
Sounds good to me, @DomInvivo would you interested in implementing it? cc: @SkafteNicki
@Borda It's no longer a priority for me, I found a way to achieve what I needed since I only needed weights of 1 and 0. Unfortunately, I do not have time at the moment but could consider it later.
@Borda is this still available? I would be interested in working on it.
@matsumotosan Yes it is. Feel free to gibe it a shot and we would appreciate a contribution. If you're getting stuck somewhere let us know. Also open a draft PR as early as possible so that we can review early on :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.