Faster collection and more metrics!
We are excited to announce that TorchMetrics v0.8 is now available. The release includes several new metrics in the classification and image domains and some performance improvements for those working with metrics collections.
Metric collections just got faster
Common wisdom dictates that you should never evaluate the performance of your models using only a single metric but instead a collection of metrics. For example, it is common to simultaneously evaluate the accuracy, precision, recall, and f1 score in classification. In TorchMetrics, we have for a long time provided the MetricCollection object for chaining such metrics together for an easy interface to calculate them all at once. However, in many cases, such a collection of metrics shares some of the underlying computations that have been repeated for every metric in the collection. In Torchmetrics v0.8 we have introduced the concept of compute_groups to MetricCollection that will, as default, be auto-detected and group metrics that share some of the same computations.
Thus, if you are using MetricCollections in your code, upgrading to TorchMetrics v0.8 should automatically make your code run faster without any code changes.
Many exciting new metrics
TorchMetrics v0.8 includes several new metrics within the classification and image domain, both for the functional and modular API. We refer to the documentation for the full description of all metrics if you want to learn more about them.
- SpectralAngleMapperor SAM was added to the image package. This metric can calculate the spectral similarity between given reference spectra and estimated spectra.
- CoverageErrorwas added to the classification package. This metric can be used when you are working with multi-label data. The metric works similar to the- sklearncounterpart and computes how far you need to go through ranked scores such that all true labels are covered.
- LabelRankingAveragePrecisionand- LabelRankingLosswere added to the classification package. Both metrics are used in multi-label ranking problems, where the goal is to give a better rank to the labels associated with each sample. Each metric gives a measure of how well your model is doing this.
- ErrorRelativeGlobalDimensionlessSynthesisor ERGAS was added to the image package. This metric can be used to calculate the accuracy of Pan sharpened images considering the normalized average error of each band of the resulting image.
- UniversalImageQualityIndexwas added to the image package. This metric can assess the difference between two images, which considers three different factors when computed: loss of correlation, luminance distortion, and contrast distortion.
- ClasswiseWrapperwas added to the wrapper package. This wrapper can be used in combinations with metrics that return multiple values (such as classification metrics with the average=None argument). The wrapper will unwrap the result into a- dictwith a label for each value.
[0.8.0] - 2022-04-14
Added
- Added WeightedMeanAbsolutePercentageErrorto regression package (#948)
- Added new classification metrics:
- Added new image metric:
- Added support for MetricCollectioninMetricTracker(#718)
- Added support for 3D image and uniform kernel in StructuralSimilarityIndexMeasure(#818)
- Added smart update of MetricCollection(#709)
- Added ClasswiseWrapperfor better logging of classification metrics with multiple output values (#832)
- Added **kwargsargument for passing additional arguments to base class (#833)
- Added negative ignore_indexfor the Accuracy metric (#362)
- Added adaptive_kfor theRetrievalPrecisionmetric (#910)
- Added reset_real_featuresargument image quality assessment metrics (#722)
- Added new keyword argument compute_on_cputo all metrics (#867)
Changed
- Made num_classesinjaccard_indexa required argument (#853, #914)
- Added normalizer, tokenizer to ROUGE metric (#838)
- Improved shape checking of permutation_invariant_training(#864)
- Allowed reduction None(#891)
- MetricTracker.best_metricwill now give a warning when computing on metric that do not have a best (#913)
Deprecated
- Deprecated argument compute_on_step(#792)
- Deprecated passing in dist_sync_on_step,process_group,dist_sync_fndirect argument (#833)
Removed
- Removed support for versions of Lightning lower than v1.5 (#788)
- Removed deprecated functions, and warnings in Text (#773)
- WERand- functional.wer
 
- Removed deprecated functions and warnings in Image (#796)
- SSIMand- functional.ssim
- PSNRand- functional.psnr
 
- Removed deprecated functions, and warnings in classification and regression (#806)
- FBetaand- functional.fbeta
- F1and- functional.f1
- Hingeand- functional.hinge
- IoUand- functional.iou
- MatthewsCorrcoef
- PearsonCorrcoef
- SpearmanCorrcoef
 
- Removed deprecated functions, and warnings in detection and pairwise (#804)
- MAPand- functional.pairwise.manhatten
 
- Removed deprecated functions, and warnings in Audio (#805)
- PESQand- functional.audio.pesq
- PITand- functional.audio.pit
- SDRand- functional.audio.sdrand- functional.audio.si_sdr
- SNRand- functional.audio.snrand- functional.audio.si_snr
- STOIand- functional.audio.stoi
 
Fixed
- Fixed device mismatch for MAPmetric in specific cases (#950)
- Improved testing speed (#820)
- Fixed compatibility of ClasswiseWrapperwith theprefixargument ofMetricCollection(#843)
- Fixed BestScoreon GPU (#912)
- Fixed Lsum computation for ROUGEScore(#944)
Contributors
@ankitaS11, @ashutoshml, @Borda, @hookSSi, @justusschock, @lucadiliello, @quancs, @rusty1s, @SkafteNicki, @stancld, @vumichien, @weningerleon, @yassersouri
If we forgot someone due to not matching commit email with GitHub account, let us know :]