diff --git a/ignite/contrib/metrics/average_precision.py b/ignite/contrib/metrics/average_precision.py index dc2b197156ca..e0d1e138b7cb 100644 --- a/ignite/contrib/metrics/average_precision.py +++ b/ignite/contrib/metrics/average_precision.py @@ -22,11 +22,11 @@ class AveragePrecision(EpochMetric): sklearn.metrics.average_precision_score.html#sklearn.metrics.average_precision_score>`_ . Args: - output_transform (callable, optional): a callable that is used to transform the + output_transform: a callable that is used to transform the :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the form expected by the metric. This can be useful if, for example, you have a multi-output model and you want to compute the metric with respect to one of the outputs. - check_compute_fn (bool): Default False. If True, `average_precision_score + check_compute_fn: Default False. If True, `average_precision_score `_ is run on the first batch of data to ensure there are no issues. User will be warned in case there are any issues computing the function. diff --git a/ignite/contrib/metrics/precision_recall_curve.py b/ignite/contrib/metrics/precision_recall_curve.py index 95016a2eb16d..d800784a145b 100644 --- a/ignite/contrib/metrics/precision_recall_curve.py +++ b/ignite/contrib/metrics/precision_recall_curve.py @@ -23,11 +23,11 @@ class PrecisionRecallCurve(EpochMetric): sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve>`_ . Args: - output_transform (callable, optional): a callable that is used to transform the + output_transform: a callable that is used to transform the :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the form expected by the metric. This can be useful if, for example, you have a multi-output model and you want to compute the metric with respect to one of the outputs. - check_compute_fn (bool): Default False. If True, `precision_recall_curve + check_compute_fn: Default False. If True, `precision_recall_curve `_ is run on the first batch of data to ensure there are no issues. User will be warned in case there are any issues computing the function. diff --git a/ignite/contrib/metrics/regression/canberra_metric.py b/ignite/contrib/metrics/regression/canberra_metric.py index c3fc17e06cf1..c0c81de49105 100644 --- a/ignite/contrib/metrics/regression/canberra_metric.py +++ b/ignite/contrib/metrics/regression/canberra_metric.py @@ -22,17 +22,24 @@ class CanberraMetric(_BaseRegression): .. _scikit-learn distance metrics: https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. + .. versionchanged:: 0.4.3 - Fixed implementation: ``abs`` in denominator. - Works with DDP. """ - def __init__( - self, output_transform: Callable = lambda x: x, device: Union[str, torch.device] = torch.device("cpu") - ) -> None: - super(CanberraMetric, self).__init__(output_transform, device) - @reinit__is_reduced def reset(self) -> None: self._sum_of_errors = torch.tensor(0.0, device=self._device) diff --git a/ignite/contrib/metrics/regression/fractional_absolute_error.py b/ignite/contrib/metrics/regression/fractional_absolute_error.py index 1e3cd93b04a2..a76e07e59800 100644 --- a/ignite/contrib/metrics/regression/fractional_absolute_error.py +++ b/ignite/contrib/metrics/regression/fractional_absolute_error.py @@ -20,6 +20,18 @@ class FractionalAbsoluteError(_BaseRegression): - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`. __ https://arxiv.org/abs/1809.03006 + + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/regression/fractional_bias.py b/ignite/contrib/metrics/regression/fractional_bias.py index 5806243a9c9e..ba362512ad76 100644 --- a/ignite/contrib/metrics/regression/fractional_bias.py +++ b/ignite/contrib/metrics/regression/fractional_bias.py @@ -21,6 +21,17 @@ class FractionalBias(_BaseRegression): __ https://arxiv.org/abs/1809.03006 + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/regression/geometric_mean_absolute_error.py b/ignite/contrib/metrics/regression/geometric_mean_absolute_error.py index 7e3db6bec67e..a3aec7fae992 100644 --- a/ignite/contrib/metrics/regression/geometric_mean_absolute_error.py +++ b/ignite/contrib/metrics/regression/geometric_mean_absolute_error.py @@ -20,6 +20,18 @@ class GeometricMeanAbsoluteError(_BaseRegression): - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`. __ https://arxiv.org/abs/1809.03006 + + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/regression/geometric_mean_relative_absolute_error.py b/ignite/contrib/metrics/regression/geometric_mean_relative_absolute_error.py index 89bda597b370..35a1817fae2a 100644 --- a/ignite/contrib/metrics/regression/geometric_mean_relative_absolute_error.py +++ b/ignite/contrib/metrics/regression/geometric_mean_relative_absolute_error.py @@ -19,9 +19,19 @@ class GeometricMeanRelativeAbsoluteError(_BaseRegression): - ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`. - __ https://arxiv.org/abs/1809.03006 + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/regression/manhattan_distance.py b/ignite/contrib/metrics/regression/manhattan_distance.py index 9d884196f17b..e0e308328fd9 100644 --- a/ignite/contrib/metrics/regression/manhattan_distance.py +++ b/ignite/contrib/metrics/regression/manhattan_distance.py @@ -21,17 +21,24 @@ class ManhattanDistance(_BaseRegression): __ https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. + .. versionchanged:: 0.4.3 - Fixed sklearn compatibility. - Workes with DDP. """ - def __init__( - self, output_transform: Callable = lambda x: x, device: Union[str, torch.device] = torch.device("cpu") - ): - super(ManhattanDistance, self).__init__(output_transform, device) - @reinit__is_reduced def reset(self) -> None: self._sum_of_errors = torch.tensor(0.0, device=self._device) diff --git a/ignite/contrib/metrics/regression/maximum_absolute_error.py b/ignite/contrib/metrics/regression/maximum_absolute_error.py index be248d784a03..a6e1b49073d8 100644 --- a/ignite/contrib/metrics/regression/maximum_absolute_error.py +++ b/ignite/contrib/metrics/regression/maximum_absolute_error.py @@ -21,6 +21,17 @@ class MaximumAbsoluteError(_BaseRegression): __ https://arxiv.org/abs/1809.03006 + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/regression/mean_absolute_relative_error.py b/ignite/contrib/metrics/regression/mean_absolute_relative_error.py index 1b448a6387a3..faac99ddb6c3 100644 --- a/ignite/contrib/metrics/regression/mean_absolute_relative_error.py +++ b/ignite/contrib/metrics/regression/mean_absolute_relative_error.py @@ -21,6 +21,17 @@ class MeanAbsoluteRelativeError(_BaseRegression): __ https://arxiv.org/ftp/arxiv/papers/1809/1809.03006.pdf + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/regression/mean_error.py b/ignite/contrib/metrics/regression/mean_error.py index cc537f3faf53..e6b0905748ca 100644 --- a/ignite/contrib/metrics/regression/mean_error.py +++ b/ignite/contrib/metrics/regression/mean_error.py @@ -21,6 +21,17 @@ class MeanError(_BaseRegression): __ https://arxiv.org/abs/1809.03006 + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/regression/mean_normalized_bias.py b/ignite/contrib/metrics/regression/mean_normalized_bias.py index d10ec9170b00..b94594a29780 100644 --- a/ignite/contrib/metrics/regression/mean_normalized_bias.py +++ b/ignite/contrib/metrics/regression/mean_normalized_bias.py @@ -21,6 +21,17 @@ class MeanNormalizedBias(_BaseRegression): __ https://arxiv.org/abs/1809.03006 + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/regression/median_absolute_error.py b/ignite/contrib/metrics/regression/median_absolute_error.py index a99f392a126d..1c490f1a380a 100644 --- a/ignite/contrib/metrics/regression/median_absolute_error.py +++ b/ignite/contrib/metrics/regression/median_absolute_error.py @@ -31,6 +31,12 @@ class MedianAbsoluteError(_BaseRegressionEpoch): __ https://arxiv.org/abs/1809.03006 + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. """ def __init__(self, output_transform: Callable = lambda x: x): diff --git a/ignite/contrib/metrics/regression/median_absolute_percentage_error.py b/ignite/contrib/metrics/regression/median_absolute_percentage_error.py index 54929e6b642e..5358f25c43a2 100644 --- a/ignite/contrib/metrics/regression/median_absolute_percentage_error.py +++ b/ignite/contrib/metrics/regression/median_absolute_percentage_error.py @@ -31,6 +31,12 @@ class MedianAbsolutePercentageError(_BaseRegressionEpoch): __ https://arxiv.org/abs/1809.03006 + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. """ def __init__(self, output_transform: Callable = lambda x: x): diff --git a/ignite/contrib/metrics/regression/median_relative_absolute_error.py b/ignite/contrib/metrics/regression/median_relative_absolute_error.py index 1d61f9fc7d7a..c797c41cbc66 100644 --- a/ignite/contrib/metrics/regression/median_relative_absolute_error.py +++ b/ignite/contrib/metrics/regression/median_relative_absolute_error.py @@ -31,6 +31,12 @@ class MedianRelativeAbsoluteError(_BaseRegressionEpoch): __ https://arxiv.org/abs/1809.03006 + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. """ def __init__(self, output_transform: Callable = lambda x: x): diff --git a/ignite/contrib/metrics/regression/r2_score.py b/ignite/contrib/metrics/regression/r2_score.py index f48adf22e33d..f420ca80d5bc 100644 --- a/ignite/contrib/metrics/regression/r2_score.py +++ b/ignite/contrib/metrics/regression/r2_score.py @@ -20,15 +20,22 @@ class R2Score(_BaseRegression): - ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)` and of type `float32`. + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. + .. versionchanged:: 0.4.3 Works with DDP. """ - def __init__( - self, output_transform: Callable = lambda x: x, device: Union[str, torch.device] = torch.device("cpu"), - ): - super(R2Score, self).__init__(output_transform, device) - @reinit__is_reduced def reset(self) -> None: self._num_examples = 0 diff --git a/ignite/contrib/metrics/regression/wave_hedges_distance.py b/ignite/contrib/metrics/regression/wave_hedges_distance.py index 6e436ba68136..9bf1248a4e1d 100644 --- a/ignite/contrib/metrics/regression/wave_hedges_distance.py +++ b/ignite/contrib/metrics/regression/wave_hedges_distance.py @@ -19,6 +19,18 @@ class WaveHedgesDistance(_BaseRegression): - `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`. __ https://arxiv.org/abs/1809.03006 + + Parameters are inherited from ``Metric.__init__``. + + Args: + output_transform: a callable that is used to transform the + :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``. + device: specifies which device updates are accumulated on. Setting the + metric's device to be the same as your ``update`` arguments ensures the ``update`` method is + non-blocking. By default, CPU. """ def reset(self) -> None: diff --git a/ignite/contrib/metrics/roc_auc.py b/ignite/contrib/metrics/roc_auc.py index c54492be862f..750835d08b0c 100644 --- a/ignite/contrib/metrics/roc_auc.py +++ b/ignite/contrib/metrics/roc_auc.py @@ -34,11 +34,11 @@ class ROC_AUC(EpochMetric): sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score>`_ . Args: - output_transform (callable, optional): a callable that is used to transform the + output_transform: a callable that is used to transform the :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the form expected by the metric. This can be useful if, for example, you have a multi-output model and you want to compute the metric with respect to one of the outputs. - check_compute_fn (bool): Default False. If True, `roc_curve + check_compute_fn: Default False. If True, `roc_curve `_ is run on the first batch of data to ensure there are no issues. User will be warned in case there are any issues computing the function. @@ -70,11 +70,11 @@ class RocCurve(EpochMetric): sklearn.metrics.roc_curve.html#sklearn.metrics.roc_curve>`_ . Args: - output_transform (callable, optional): a callable that is used to transform the + output_transform: a callable that is used to transform the :class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the form expected by the metric. This can be useful if, for example, you have a multi-output model and you want to compute the metric with respect to one of the outputs. - check_compute_fn (bool): Default False. If True, `sklearn.metrics.roc_curve + check_compute_fn: Default False. If True, `sklearn.metrics.roc_curve `_ is run on the first batch of data to ensure there are no issues. User will be warned in case there are any issues computing the function.