Skip to content

Add weights for the pearson, spearman, and r2_score #1235

@DomInvivo

Description

@DomInvivo

🚀 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions