Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ignite/contrib/metrics/average_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<http://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html
#sklearn.metrics.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.
Expand Down
4 changes: 2 additions & 2 deletions ignite/contrib/metrics/precision_recall_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html
#sklearn.metrics.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.
Expand Down
17 changes: 12 additions & 5 deletions ignite/contrib/metrics/regression/canberra_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions ignite/contrib/metrics/regression/fractional_absolute_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions ignite/contrib/metrics/regression/fractional_bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions ignite/contrib/metrics/regression/geometric_mean_absolute_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 12 additions & 5 deletions ignite/contrib/metrics/regression/manhattan_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions ignite/contrib/metrics/regression/maximum_absolute_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions ignite/contrib/metrics/regression/mean_absolute_relative_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions ignite/contrib/metrics/regression/mean_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions ignite/contrib/metrics/regression/mean_normalized_bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions ignite/contrib/metrics/regression/median_absolute_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
17 changes: 12 additions & 5 deletions ignite/contrib/metrics/regression/r2_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions ignite/contrib/metrics/regression/wave_hedges_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions ignite/contrib/metrics/roc_auc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<http://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html#
sklearn.metrics.roc_auc_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.
Expand Down Expand Up @@ -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
<http://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_curve.html#
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.
Expand Down