torchmetrics icon indicating copy to clipboard operation
torchmetrics copied to clipboard

add optional ignore_index in all metrics

Open fabricecarles opened this issue 1 year ago • 1 comments

🚀 Feature

Could you please consider incorporating a systematically optional ignore_index argument in all metrics?

For instance, in classification tasks, we currently have the ability to use ignore_index as follows:

torchmetrics.classification.MulticlassJaccardIndex(num_classes=15, ignore_index=255)

However, in the case of regression, there is currently no mechanism to utilize ignore_index when computing metrics such as MSE or MAE.

Motivation

There is a plethora of datasets for regression tasks (but not limited to regression) that contain pixel values representing missing data. It is crucial to have the capability to ignore these values when computing metric statistics.

Pitch

I suggest that all metrics be updated to implement an optional ignore_index argument.

Alternatives

Is it feasible to incorporate the ignore_index functionality in advanced metric settings? For example, as shown in https://lightning.ai/docs/torchmetrics/stable/pages/overview.html#metric-kwargs

Additional context

For instance, in the context of depth maps, ground truth data may contain missing values replaced with an arbitrary ignore_index, and the training loss is already designed to ignore them. This feature would provide consistency and flexibility across various metrics.

fabricecarles avatar Dec 18 '23 12:12 fabricecarles

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

github-actions[bot] avatar Dec 18 '23 12:12 github-actions[bot]