diff --git a/CHANGELOG.md b/CHANGELOG.md index f4c07de9ad6..cfb24ba1ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `PSNR` +- Removed deprecated functions, and warnings in classification and regression ([#806](https://github.com/PyTorchLightning/metrics/pull/806)) + * `FBeta` + * `F1` + * `Hinge` + * `IoU` + * `functional.iou` + * `MatthewsCorrcoef` + * `PearsonCorrcoef` + * `SpearmanCorrcoef` + * `functional.fbeta` + * `functional.f1` + * `functional.hinge` + + + - Removed deprecated functions, and warnings in detection and pairwise ([#804](https://github.com/PyTorchLightning/metrics/pull/804)) * `MAP` * `functional.pairwise.manhatten` diff --git a/torchmetrics/__init__.py b/torchmetrics/__init__.py index d522762d78c..d3990fb2cf7 100644 --- a/torchmetrics/__init__.py +++ b/torchmetrics/__init__.py @@ -20,10 +20,9 @@ SignalDistortionRatio, SignalNoiseRatio, ) -from torchmetrics.classification import ( # noqa: E402, F401 +from torchmetrics.classification import ( # noqa: E402 AUC, AUROC, - F1, ROC, Accuracy, AveragePrecision, @@ -34,15 +33,11 @@ CohenKappa, ConfusionMatrix, F1Score, - FBeta, FBetaScore, HammingDistance, - Hinge, HingeLoss, - IoU, JaccardIndex, KLDivergence, - MatthewsCorrcoef, MatthewsCorrCoef, Precision, PrecisionRecallCurve, @@ -64,10 +59,8 @@ MeanAbsolutePercentageError, MeanSquaredError, MeanSquaredLogError, - PearsonCorrcoef, PearsonCorrCoef, R2Score, - SpearmanCorrcoef, SpearmanCorrCoef, SymmetricMeanAbsolutePercentageError, TweedieDevianceScore, @@ -117,16 +110,12 @@ "TweedieDevianceScore", "ExplainedVariance", "ExtendedEditDistance", - "F1", "F1Score", - "FBeta", "FBetaScore", "HammingDistance", - "Hinge", "HingeLoss", "JaccardIndex", "KLDivergence", - "MatthewsCorrcoef", "MatthewsCorrCoef", "MaxMetric", "MeanAbsoluteError", @@ -141,7 +130,6 @@ "MinMetric", "MultioutputWrapper", "MultiScaleStructuralSimilarityIndexMeasure", - "PearsonCorrcoef", "PearsonCorrCoef", "PermutationInvariantTraining", "Precision", @@ -163,7 +151,6 @@ "ScaleInvariantSignalDistortionRatio", "ScaleInvariantSignalNoiseRatio", "SignalNoiseRatio", - "SpearmanCorrcoef", "SpearmanCorrCoef", "Specificity", "SQuAD", diff --git a/torchmetrics/classification/__init__.py b/torchmetrics/classification/__init__.py index 734b37153c6..996d61e5a46 100644 --- a/torchmetrics/classification/__init__.py +++ b/torchmetrics/classification/__init__.py @@ -21,13 +21,12 @@ from torchmetrics.classification.calibration_error import CalibrationError # noqa: F401 from torchmetrics.classification.cohen_kappa import CohenKappa # noqa: F401 from torchmetrics.classification.confusion_matrix import ConfusionMatrix # noqa: F401 -from torchmetrics.classification.f_beta import F1, F1Score, FBeta, FBetaScore # noqa: F401 +from torchmetrics.classification.f_beta import F1Score, FBetaScore # noqa: F401 from torchmetrics.classification.hamming import HammingDistance # noqa: F401 -from torchmetrics.classification.hinge import Hinge, HingeLoss # noqa: F401 -from torchmetrics.classification.iou import IoU # noqa: F401 +from torchmetrics.classification.hinge import HingeLoss # noqa: F401 from torchmetrics.classification.jaccard import JaccardIndex # noqa: F401 from torchmetrics.classification.kl_divergence import KLDivergence # noqa: F401 -from torchmetrics.classification.matthews_corrcoef import MatthewsCorrCoef, MatthewsCorrcoef # noqa: F401 +from torchmetrics.classification.matthews_corrcoef import MatthewsCorrCoef # noqa: F401 from torchmetrics.classification.precision_recall import Precision, Recall # noqa: F401 from torchmetrics.classification.precision_recall_curve import PrecisionRecallCurve # noqa: F401 from torchmetrics.classification.roc import ROC # noqa: F401 diff --git a/torchmetrics/classification/f_beta.py b/torchmetrics/classification/f_beta.py index 0a716964453..24ad3bc47ca 100644 --- a/torchmetrics/classification/f_beta.py +++ b/torchmetrics/classification/f_beta.py @@ -14,12 +14,10 @@ from typing import Any, Callable, Optional import torch -from deprecate import deprecated, void from torch import Tensor from torchmetrics.classification.stat_scores import StatScores from torchmetrics.functional.classification.f_beta import _fbeta_compute -from torchmetrics.utilities import _future_warning from torchmetrics.utilities.enums import AverageMethod @@ -176,51 +174,6 @@ def compute(self) -> Tensor: return _fbeta_compute(tp, fp, tn, fn, self.beta, self.ignore_index, self.average, self.mdmc_reduce) -class FBeta(FBetaScore): - r""" - Computes `F-score`_, specifically: - - .. deprecated:: v0.7 - Use :class:`torchmetrics.FBetaScore`. Will be removed in v0.8. - - Example:: - >>> f_beta = FBetaScore(num_classes=3, beta=0.5) - >>> f_beta(torch.tensor([0, 2, 1, 0, 0, 1]), torch.tensor([0, 1, 2, 0, 1, 2])) - tensor(0.3333) - """ - - @deprecated(target=FBetaScore, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) - def __init__( - self, - num_classes: Optional[int] = None, - beta: float = 1.0, - threshold: float = 0.5, - average: str = "micro", - mdmc_average: Optional[str] = None, - ignore_index: Optional[int] = None, - top_k: Optional[int] = None, - multiclass: Optional[bool] = None, - compute_on_step: bool = True, - dist_sync_on_step: bool = False, - process_group: Optional[Any] = None, - dist_sync_fn: Callable = None, - ) -> None: - void( - num_classes, - beta, - threshold, - average, - mdmc_average, - ignore_index, - top_k, - multiclass, - compute_on_step, - dist_sync_on_step, - process_group, - dist_sync_fn, - ) - - class F1Score(FBetaScore): """Computes F1 metric. F1 metrics correspond to a harmonic mean of the precision and recall scores. @@ -347,48 +300,3 @@ def __init__( process_group=process_group, dist_sync_fn=dist_sync_fn, ) - - -class F1(F1Score): - """Computes F1 metric. F1 metrics correspond to a harmonic mean of the precision and recall scores. - - .. deprecated:: v0.7 - Use :class:`torchmetrics.F1Score`. Will be removed in v0.8. - - Example: - >>> from torchmetrics import F1 - >>> target = torch.tensor([0, 1, 2, 0, 1, 2]) - >>> preds = torch.tensor([0, 2, 1, 0, 0, 1]) - >>> f1 = F1(num_classes=3) - >>> f1(preds, target) - tensor(0.3333) - """ - - @deprecated(target=F1Score, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) - def __init__( - self, - num_classes: Optional[int] = None, - threshold: float = 0.5, - average: str = "micro", - mdmc_average: Optional[str] = None, - ignore_index: Optional[int] = None, - top_k: Optional[int] = None, - multiclass: Optional[bool] = None, - compute_on_step: bool = True, - dist_sync_on_step: bool = False, - process_group: Optional[Any] = None, - dist_sync_fn: Callable = None, - ) -> None: - void( - num_classes, - threshold, - average, - mdmc_average, - ignore_index, - top_k, - multiclass, - compute_on_step, - dist_sync_on_step, - process_group, - dist_sync_fn, - ) diff --git a/torchmetrics/classification/hinge.py b/torchmetrics/classification/hinge.py index 04b4736cb22..ac69491d97e 100644 --- a/torchmetrics/classification/hinge.py +++ b/torchmetrics/classification/hinge.py @@ -13,12 +13,10 @@ # limitations under the License. from typing import Any, Callable, Optional, Union -from deprecate import deprecated, void from torch import Tensor, tensor from torchmetrics.functional.classification.hinge import MulticlassMode, _hinge_compute, _hinge_update from torchmetrics.metric import Metric -from torchmetrics.utilities import _future_warning class HingeLoss(Metric): @@ -128,41 +126,3 @@ def update(self, preds: Tensor, target: Tensor) -> None: # type: ignore def compute(self) -> Tensor: return _hinge_compute(self.measure, self.total) - - -class Hinge(HingeLoss): - r""" - Computes the mean `Hinge loss`_, typically used for Support Vector Machines (SVMs). - - .. deprecated:: v0.7 - Use :class:`torchmetrics.HingeLoss`. Will be removed in v0.8. - - Example (binary case): - >>> import torch - >>> hinge = Hinge() - >>> hinge(torch.tensor([-2.2, 2.4, 0.1]), torch.tensor([0, 1, 1])) - tensor(0.3000) - - Example (default / multiclass case): - >>> hinge = Hinge() - >>> hinge(torch.tensor([[-1.0, 0.9, 0.2], [0.5, -1.1, 0.8], [2.2, -0.5, 0.3]]), torch.tensor([0, 1, 2])) - tensor(2.9000) - - Example (multiclass example, one vs all mode): - >>> hinge = Hinge(multiclass_mode="one-vs-all") - >>> hinge(torch.tensor([[-1.0, 0.9, 0.2], [0.5, -1.1, 0.8], [2.2, -0.5, 0.3]]), torch.tensor([0, 1, 2])) - tensor([2.2333, 1.5000, 1.2333]) - - """ - - @deprecated(target=HingeLoss, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) - def __init__( - self, - squared: bool = False, - multiclass_mode: Optional[Union[str, MulticlassMode]] = None, - compute_on_step: bool = True, - dist_sync_on_step: bool = False, - process_group: Optional[Any] = None, - dist_sync_fn: Callable = None, - ) -> None: - void(squared, multiclass_mode, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn) diff --git a/torchmetrics/classification/iou.py b/torchmetrics/classification/iou.py deleted file mode 100644 index d11a9afab83..00000000000 --- a/torchmetrics/classification/iou.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright The PyTorch Lightning team. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from typing import Any, Optional - -import torch -from deprecate import deprecated, void - -from torchmetrics.classification.jaccard import JaccardIndex -from torchmetrics.utilities import _future_warning - - -class IoU(JaccardIndex): - r""" - Computes Intersection over union, or `Jaccard index`_: - - .. deprecated:: v0.7 - Use :class:`torchmetrics.JaccardIndex`. Will be removed in v0.8. - - Example: - >>> from torchmetrics import IoU - >>> target = torch.randint(0, 2, (10, 25, 25)) - >>> pred = torch.tensor(target) - >>> pred[2:5, 7:13, 9:15] = 1 - pred[2:5, 7:13, 9:15] - >>> iou = IoU(num_classes=2) - >>> iou(pred, target) - tensor(0.9660) - - """ - - @deprecated(target=JaccardIndex, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) - def __init__( - self, - num_classes: int, - ignore_index: Optional[int] = None, - absent_score: float = 0.0, - threshold: float = 0.5, - reduction: str = "elementwise_mean", - compute_on_step: bool = True, - dist_sync_on_step: bool = False, - process_group: Optional[Any] = None, - ) -> None: - void( - num_classes, - ignore_index, - absent_score, - threshold, - reduction, - compute_on_step, - dist_sync_on_step, - process_group, - ) diff --git a/torchmetrics/classification/matthews_corrcoef.py b/torchmetrics/classification/matthews_corrcoef.py index ffe96767666..c643927f314 100644 --- a/torchmetrics/classification/matthews_corrcoef.py +++ b/torchmetrics/classification/matthews_corrcoef.py @@ -14,7 +14,6 @@ from typing import Any, Callable, Optional import torch -from deprecate import deprecated, void from torch import Tensor from torchmetrics.functional.classification.matthews_corrcoef import ( @@ -22,7 +21,6 @@ _matthews_corrcoef_update, ) from torchmetrics.metric import Metric -from torchmetrics.utilities import _future_warning class MatthewsCorrCoef(Metric): @@ -112,29 +110,3 @@ def update(self, preds: Tensor, target: Tensor) -> None: # type: ignore def compute(self) -> Tensor: """Computes matthews correlation coefficient.""" return _matthews_corrcoef_compute(self.confmat) - - -class MatthewsCorrcoef(MatthewsCorrCoef): - """Calculates `Matthews correlation coefficient`_ that measures the general correlation or quality of a - classification. - - Example: - >>> matthews_corrcoef = MatthewsCorrcoef(num_classes=2) - >>> matthews_corrcoef(torch.tensor([0, 1, 0, 0]), torch.tensor([1, 1, 0, 0])) - tensor(0.5774) - - .. deprecated:: v0.7 - Renamed in favor of :class:`torchmetrics.MatthewsCorrCoef`. Will be removed in v0.8. - """ - - @deprecated(target=MatthewsCorrCoef, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) - def __init__( - self, - num_classes: int, - threshold: float = 0.5, - compute_on_step: bool = True, - dist_sync_on_step: bool = False, - process_group: Optional[Any] = None, - dist_sync_fn: Callable = None, - ) -> None: - void(num_classes, threshold, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn) diff --git a/torchmetrics/functional/__init__.py b/torchmetrics/functional/__init__.py index 25fa04ba54b..e4fde19deb7 100644 --- a/torchmetrics/functional/__init__.py +++ b/torchmetrics/functional/__init__.py @@ -22,10 +22,9 @@ from torchmetrics.functional.classification.cohen_kappa import cohen_kappa from torchmetrics.functional.classification.confusion_matrix import confusion_matrix from torchmetrics.functional.classification.dice import dice_score -from torchmetrics.functional.classification.f_beta import f1, f1_score, fbeta, fbeta_score +from torchmetrics.functional.classification.f_beta import f1_score, fbeta_score from torchmetrics.functional.classification.hamming import hamming_distance -from torchmetrics.functional.classification.hinge import hinge, hinge_loss -from torchmetrics.functional.classification.iou import iou # noqa: F401 +from torchmetrics.functional.classification.hinge import hinge_loss from torchmetrics.functional.classification.jaccard import jaccard_index from torchmetrics.functional.classification.kl_divergence import kl_divergence from torchmetrics.functional.classification.matthews_corrcoef import matthews_corrcoef @@ -95,12 +94,9 @@ "dice_score", "explained_variance", "extended_edit_distance", - "f1", "f1_score", - "fbeta", "fbeta_score", "hamming_distance", - "hinge", "hinge_loss", "image_gradients", "jaccard_index", diff --git a/torchmetrics/functional/classification/__init__.py b/torchmetrics/functional/classification/__init__.py index 70743f93e86..513c59fb842 100644 --- a/torchmetrics/functional/classification/__init__.py +++ b/torchmetrics/functional/classification/__init__.py @@ -19,9 +19,9 @@ from torchmetrics.functional.classification.cohen_kappa import cohen_kappa # noqa: F401 from torchmetrics.functional.classification.confusion_matrix import confusion_matrix # noqa: F401 from torchmetrics.functional.classification.dice import dice_score # noqa: F401 -from torchmetrics.functional.classification.f_beta import f1, f1_score, fbeta, fbeta_score # noqa: F401 +from torchmetrics.functional.classification.f_beta import f1_score, fbeta_score # noqa: F401 from torchmetrics.functional.classification.hamming import hamming_distance # noqa: F401 -from torchmetrics.functional.classification.hinge import hinge, hinge_loss # noqa: F401 +from torchmetrics.functional.classification.hinge import hinge_loss # noqa: F401 from torchmetrics.functional.classification.jaccard import jaccard_index # noqa: F401 from torchmetrics.functional.classification.kl_divergence import kl_divergence # noqa: F401 from torchmetrics.functional.classification.matthews_corrcoef import matthews_corrcoef # noqa: F401 diff --git a/torchmetrics/functional/classification/f_beta.py b/torchmetrics/functional/classification/f_beta.py index 60571603b8a..f6273e9f982 100644 --- a/torchmetrics/functional/classification/f_beta.py +++ b/torchmetrics/functional/classification/f_beta.py @@ -14,11 +14,9 @@ from typing import Optional import torch -from deprecate import deprecated, void from torch import Tensor from torchmetrics.functional.classification.stat_scores import _reduce_stat_scores, _stat_scores_update -from torchmetrics.utilities import _future_warning from torchmetrics.utilities.enums import AverageMethod as AvgMethod from torchmetrics.utilities.enums import MDMCAverageMethod @@ -245,32 +243,6 @@ def fbeta_score( return _fbeta_compute(tp, fp, tn, fn, beta, ignore_index, average, mdmc_average) -@deprecated(target=fbeta_score, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) -def fbeta( - preds: Tensor, - target: Tensor, - beta: float = 1.0, - average: str = "micro", - mdmc_average: Optional[str] = None, - ignore_index: Optional[int] = None, - num_classes: Optional[int] = None, - threshold: float = 0.5, - top_k: Optional[int] = None, - multiclass: Optional[bool] = None, -) -> Tensor: - r""" - Computes f_beta metric. - - .. deprecated:: v0.7 - Use :class:`torchmetrics.functional.f1_score`. Will be removed in v0.8. - - Example:: - >>> fbeta(torch.tensor([0, 2, 1, 0, 0, 1]), torch.tensor([0, 1, 2, 0, 1, 2]), num_classes=3, beta=0.5) - tensor(0.3333) - """ - return void(preds, target, beta, average, mdmc_average, ignore_index, num_classes, threshold, top_k, multiclass) - - def f1_score( preds: Tensor, target: Tensor, @@ -379,31 +351,3 @@ def f1_score( return fbeta_score( preds, target, 1.0, average, mdmc_average, ignore_index, num_classes, threshold, top_k, multiclass ) - - -@deprecated(target=f1_score, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) -def f1( - preds: Tensor, - target: Tensor, - beta: float = 1.0, - average: str = "micro", - mdmc_average: Optional[str] = None, - ignore_index: Optional[int] = None, - num_classes: Optional[int] = None, - threshold: float = 0.5, - top_k: Optional[int] = None, - multiclass: Optional[bool] = None, -) -> Tensor: - """Computes F1 metric. F1 metrics correspond to a equally weighted average of the precision and recall scores. - - .. deprecated:: v0.7 - Use :class:`torchmetrics.functional.f1_score`. Will be removed in v0.8. - - Example: - >>> from torchmetrics.functional import f1 - >>> target = torch.tensor([0, 1, 2, 0, 1, 2]) - >>> preds = torch.tensor([0, 2, 1, 0, 0, 1]) - >>> f1(preds, target, num_classes=3) - tensor(0.3333) - """ - return void(preds, target, beta, average, mdmc_average, ignore_index, num_classes, threshold, top_k, multiclass) diff --git a/torchmetrics/functional/classification/hinge.py b/torchmetrics/functional/classification/hinge.py index 649d3c8a5d6..e1a3320bc18 100644 --- a/torchmetrics/functional/classification/hinge.py +++ b/torchmetrics/functional/classification/hinge.py @@ -14,10 +14,8 @@ from typing import Optional, Tuple, Union import torch -from deprecate import deprecated, void from torch import Tensor, tensor -from torchmetrics.utilities import _future_warning from torchmetrics.utilities.checks import _input_squeeze from torchmetrics.utilities.data import to_onehot from torchmetrics.utilities.enums import DataType, EnumStr @@ -231,34 +229,3 @@ def hinge_loss( """ measure, total = _hinge_update(preds, target, squared=squared, multiclass_mode=multiclass_mode) return _hinge_compute(measure, total) - - -@deprecated(target=hinge_loss, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) -def hinge( - preds: Tensor, - target: Tensor, - squared: bool = False, - multiclass_mode: Optional[Union[str, MulticlassMode]] = None, -) -> Tensor: - r""" - Computes the mean `Hinge loss`_ typically used for Support Vector Machines (SVMs). - - .. deprecated:: v0.7 - Use :func:`torchmetrics.functional.hinge_loss`. Will be removed in v0.8. - - Example (binary case): - >>> import torch - >>> hinge(torch.tensor([-2.2, 2.4, 0.1]), torch.tensor([0, 1, 1])) - tensor(0.3000) - - Example (default / multiclass case): - >>> hinge(torch.tensor([[-1.0, 0.9, 0.2], [0.5, -1.1, 0.8], [2.2, -0.5, 0.3]]), torch.tensor([0, 1, 2])) - tensor(2.9000) - - Example (multiclass example, one vs all mode): - >>> target = torch.tensor([0, 1, 2]) - >>> preds = torch.tensor([[-1.0, 0.9, 0.2], [0.5, -1.1, 0.8], [2.2, -0.5, 0.3]]) - >>> hinge(preds, target, multiclass_mode="one-vs-all") - tensor([2.2333, 1.5000, 1.2333]) - """ - return void(preds, target, squared, multiclass_mode) diff --git a/torchmetrics/functional/classification/iou.py b/torchmetrics/functional/classification/iou.py deleted file mode 100644 index cba06f0d46d..00000000000 --- a/torchmetrics/functional/classification/iou.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright The PyTorch Lightning team. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from typing import Optional - -import torch -from deprecate import deprecated, void -from torch import Tensor - -from torchmetrics.functional.classification.jaccard import jaccard_index -from torchmetrics.utilities import _future_warning - - -@deprecated(target=jaccard_index, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) -def iou( - preds: Tensor, - target: Tensor, - ignore_index: Optional[int] = None, - absent_score: float = 0.0, - threshold: float = 0.5, - num_classes: Optional[int] = None, - reduction: str = "elementwise_mean", -) -> Tensor: - r""" - Computes `Jaccard index`_ - - .. deprecated:: v0.7 - Use :func:`torchmetrics.functional.jaccard_index`. Will be removed in v0.8. - - Example: - >>> from torchmetrics.functional import iou - >>> target = torch.randint(0, 2, (10, 25, 25)) - >>> pred = torch.tensor(target) - >>> pred[2:5, 7:13, 9:15] = 1 - pred[2:5, 7:13, 9:15] - >>> iou(pred, target) - tensor(0.9660) - """ - return void(preds, target, ignore_index, absent_score, threshold, num_classes, reduction) diff --git a/torchmetrics/regression/__init__.py b/torchmetrics/regression/__init__.py index 6522cb59ae3..0ea11d19dfc 100644 --- a/torchmetrics/regression/__init__.py +++ b/torchmetrics/regression/__init__.py @@ -17,8 +17,8 @@ from torchmetrics.regression.mae import MeanAbsoluteError # noqa: F401 from torchmetrics.regression.mape import MeanAbsolutePercentageError # noqa: F401 from torchmetrics.regression.mse import MeanSquaredError # noqa: F401 -from torchmetrics.regression.pearson import PearsonCorrCoef, PearsonCorrcoef # noqa: F401 +from torchmetrics.regression.pearson import PearsonCorrCoef # noqa: F401 from torchmetrics.regression.r2 import R2Score # noqa: F401 -from torchmetrics.regression.spearman import SpearmanCorrCoef, SpearmanCorrcoef # noqa: F401 +from torchmetrics.regression.spearman import SpearmanCorrCoef # noqa: F401 from torchmetrics.regression.symmetric_mape import SymmetricMeanAbsolutePercentageError # noqa: F401 from torchmetrics.regression.tweedie_deviance import TweedieDevianceScore # noqa: F401 diff --git a/torchmetrics/regression/pearson.py b/torchmetrics/regression/pearson.py index d4a19259c1d..8224a2e112c 100644 --- a/torchmetrics/regression/pearson.py +++ b/torchmetrics/regression/pearson.py @@ -14,12 +14,10 @@ from typing import Any, List, Optional, Tuple import torch -from deprecate import deprecated, void from torch import Tensor from torchmetrics.functional.regression.pearson import _pearson_corrcoef_compute, _pearson_corrcoef_update from torchmetrics.metric import Metric -from torchmetrics.utilities import _future_warning def _final_aggregation( @@ -141,27 +139,3 @@ def compute(self) -> Tensor: n_total = self.n_total return _pearson_corrcoef_compute(var_x, var_y, corr_xy, n_total) - - -class PearsonCorrcoef(PearsonCorrCoef): - r""" - Computes `Pearson Correlation Coefficient`_: - - Example: - >>> pearson = PearsonCorrcoef() - >>> pearson(torch.tensor([2.5, 0.0, 2, 8]), torch.tensor([3, -0.5, 2, 7])) - tensor(0.9849) - - .. deprecated:: v0.7 - Renamed in favor of :class:`torchmetrics.PearsonCorrCoef`. Will be removed in v0.8. - - """ - - @deprecated(target=PearsonCorrCoef, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) - def __init__( - self, - compute_on_step: bool = True, - dist_sync_on_step: bool = False, - process_group: Optional[Any] = None, - ) -> None: - void(compute_on_step, dist_sync_on_step, process_group) diff --git a/torchmetrics/regression/spearman.py b/torchmetrics/regression/spearman.py index 549ce77c62f..5e1ce05529c 100644 --- a/torchmetrics/regression/spearman.py +++ b/torchmetrics/regression/spearman.py @@ -14,12 +14,11 @@ from typing import Any, Callable, List, Optional import torch -from deprecate import deprecated, void from torch import Tensor from torchmetrics.functional.regression.spearman import _spearman_corrcoef_compute, _spearman_corrcoef_update from torchmetrics.metric import Metric -from torchmetrics.utilities import _future_warning, rank_zero_warn +from torchmetrics.utilities import rank_zero_warn from torchmetrics.utilities.data import dim_zero_cat @@ -96,26 +95,3 @@ def compute(self) -> Tensor: preds = dim_zero_cat(self.preds) target = dim_zero_cat(self.target) return _spearman_corrcoef_compute(preds, target) - - -class SpearmanCorrcoef(SpearmanCorrCoef): - """Computes `spearmans rank correlation coefficient`_. - - Example: - >>> spearman = SpearmanCorrCoef() - >>> spearman(torch.tensor([2.5, 0.0, 2, 8]), torch.tensor([3, -0.5, 2, 7])) - tensor(1.0000) - - .. deprecated:: v0.7 - Renamed in favor of :class:`torchmetrics.SpearmanCorrCoef`. Will be removed in v0.8. - """ - - @deprecated(target=SpearmanCorrCoef, deprecated_in="0.7", remove_in="0.8", stream=_future_warning) - def __init__( - self, - compute_on_step: bool = True, - dist_sync_on_step: bool = False, - process_group: Optional[Any] = None, - dist_sync_fn: Optional[Callable] = None, - ) -> None: - void(compute_on_step, dist_sync_on_step, process_group, dist_sync_fn)