Skip to content

Commit 930d174

Browse files
Jeff Yangvfdev-5sdesrozis
committed
docs: rm type hints in ignite.contrib.metrics (6) (#1688)
* docs: rm type hints in ignite.metrics * docs: rm type hints in ignite.distributed * docs: rm type hints in ignite.contrib.metrics * fix: sphinx back to 3.2.1 * Revert "docs: rm type hints in ignite.metrics" This reverts commit a94b50e. * Revert "docs: rm type hints in ignite.distributed" This reverts commit 2179df5. * remove unnecessary device, __init__ * add Metric.__init__ docstring for no __init__ for contrib.metrics Co-authored-by: vfdev <vfdev.5@gmail.com> Co-authored-by: Sylvain Desroziers <sylvain.desroziers@gmail.com>
1 parent 8ed0434 commit 930d174

18 files changed

+164
-24
lines changed

ignite/contrib/metrics/average_precision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class AveragePrecision(EpochMetric):
2222
sklearn.metrics.average_precision_score.html#sklearn.metrics.average_precision_score>`_ .
2323
2424
Args:
25-
output_transform (callable, optional): a callable that is used to transform the
25+
output_transform: a callable that is used to transform the
2626
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
2727
form expected by the metric. This can be useful if, for example, you have a multi-output model and
2828
you want to compute the metric with respect to one of the outputs.
29-
check_compute_fn (bool): Default False. If True, `average_precision_score
29+
check_compute_fn: Default False. If True, `average_precision_score
3030
<http://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html
3131
#sklearn.metrics.average_precision_score>`_ is run on the first batch of data to ensure there are
3232
no issues. User will be warned in case there are any issues computing the function.

ignite/contrib/metrics/precision_recall_curve.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class PrecisionRecallCurve(EpochMetric):
2323
sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve>`_ .
2424
2525
Args:
26-
output_transform (callable, optional): a callable that is used to transform the
26+
output_transform: a callable that is used to transform the
2727
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
2828
form expected by the metric. This can be useful if, for example, you have a multi-output model and
2929
you want to compute the metric with respect to one of the outputs.
30-
check_compute_fn (bool): Default False. If True, `precision_recall_curve
30+
check_compute_fn: Default False. If True, `precision_recall_curve
3131
<http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html
3232
#sklearn.metrics.precision_recall_curve>`_ is run on the first batch of data to ensure there are
3333
no issues. User will be warned in case there are any issues computing the function.

ignite/contrib/metrics/regression/canberra_metric.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,24 @@ class CanberraMetric(_BaseRegression):
2222
.. _scikit-learn distance metrics:
2323
https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html
2424
25+
Parameters are inherited from ``Metric.__init__``.
26+
27+
Args:
28+
output_transform: a callable that is used to transform the
29+
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
30+
form expected by the metric. This can be useful if, for example, you have a multi-output model and
31+
you want to compute the metric with respect to one of the outputs.
32+
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
33+
device: specifies which device updates are accumulated on. Setting the
34+
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
35+
non-blocking. By default, CPU.
36+
2537
.. versionchanged:: 0.4.3
2638
2739
- Fixed implementation: ``abs`` in denominator.
2840
- Works with DDP.
2941
"""
3042

31-
def __init__(
32-
self, output_transform: Callable = lambda x: x, device: Union[str, torch.device] = torch.device("cpu")
33-
) -> None:
34-
super(CanberraMetric, self).__init__(output_transform, device)
35-
3643
@reinit__is_reduced
3744
def reset(self) -> None:
3845
self._sum_of_errors = torch.tensor(0.0, device=self._device)

ignite/contrib/metrics/regression/fractional_absolute_error.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ class FractionalAbsoluteError(_BaseRegression):
2020
- `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`.
2121
2222
__ https://arxiv.org/abs/1809.03006
23+
24+
Parameters are inherited from ``Metric.__init__``.
25+
26+
Args:
27+
output_transform: a callable that is used to transform the
28+
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
29+
form expected by the metric. This can be useful if, for example, you have a multi-output model and
30+
you want to compute the metric with respect to one of the outputs.
31+
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
32+
device: specifies which device updates are accumulated on. Setting the
33+
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
34+
non-blocking. By default, CPU.
2335
"""
2436

2537
def reset(self) -> None:

ignite/contrib/metrics/regression/fractional_bias.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ class FractionalBias(_BaseRegression):
2121
2222
__ https://arxiv.org/abs/1809.03006
2323
24+
Parameters are inherited from ``Metric.__init__``.
25+
26+
Args:
27+
output_transform: a callable that is used to transform the
28+
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
29+
form expected by the metric. This can be useful if, for example, you have a multi-output model and
30+
you want to compute the metric with respect to one of the outputs.
31+
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
32+
device: specifies which device updates are accumulated on. Setting the
33+
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
34+
non-blocking. By default, CPU.
2435
"""
2536

2637
def reset(self) -> None:

ignite/contrib/metrics/regression/geometric_mean_absolute_error.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ class GeometricMeanAbsoluteError(_BaseRegression):
2020
- `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`.
2121
2222
__ https://arxiv.org/abs/1809.03006
23+
24+
Parameters are inherited from ``Metric.__init__``.
25+
26+
Args:
27+
output_transform: a callable that is used to transform the
28+
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
29+
form expected by the metric. This can be useful if, for example, you have a multi-output model and
30+
you want to compute the metric with respect to one of the outputs.
31+
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
32+
device: specifies which device updates are accumulated on. Setting the
33+
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
34+
non-blocking. By default, CPU.
2335
"""
2436

2537
def reset(self) -> None:

ignite/contrib/metrics/regression/geometric_mean_relative_absolute_error.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ class GeometricMeanRelativeAbsoluteError(_BaseRegression):
1919
- ``update`` must receive output of the form ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
2020
- `y` and `y_pred` must be of same shape `(N, )` or `(N, 1)`.
2121
22-
2322
__ https://arxiv.org/abs/1809.03006
2423
24+
Parameters are inherited from ``Metric.__init__``.
25+
26+
Args:
27+
output_transform: a callable that is used to transform the
28+
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
29+
form expected by the metric. This can be useful if, for example, you have a multi-output model and
30+
you want to compute the metric with respect to one of the outputs.
31+
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
32+
device: specifies which device updates are accumulated on. Setting the
33+
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
34+
non-blocking. By default, CPU.
2535
"""
2636

2737
def reset(self) -> None:

ignite/contrib/metrics/regression/manhattan_distance.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,24 @@ class ManhattanDistance(_BaseRegression):
2121
2222
__ https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html
2323
24+
Parameters are inherited from ``Metric.__init__``.
25+
26+
Args:
27+
output_transform: a callable that is used to transform the
28+
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
29+
form expected by the metric. This can be useful if, for example, you have a multi-output model and
30+
you want to compute the metric with respect to one of the outputs.
31+
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
32+
device: specifies which device updates are accumulated on. Setting the
33+
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
34+
non-blocking. By default, CPU.
35+
2436
.. versionchanged:: 0.4.3
2537
2638
- Fixed sklearn compatibility.
2739
- Workes with DDP.
2840
"""
2941

30-
def __init__(
31-
self, output_transform: Callable = lambda x: x, device: Union[str, torch.device] = torch.device("cpu")
32-
):
33-
super(ManhattanDistance, self).__init__(output_transform, device)
34-
3542
@reinit__is_reduced
3643
def reset(self) -> None:
3744
self._sum_of_errors = torch.tensor(0.0, device=self._device)

ignite/contrib/metrics/regression/maximum_absolute_error.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ class MaximumAbsoluteError(_BaseRegression):
2121
2222
__ https://arxiv.org/abs/1809.03006
2323
24+
Parameters are inherited from ``Metric.__init__``.
25+
26+
Args:
27+
output_transform: a callable that is used to transform the
28+
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
29+
form expected by the metric. This can be useful if, for example, you have a multi-output model and
30+
you want to compute the metric with respect to one of the outputs.
31+
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
32+
device: specifies which device updates are accumulated on. Setting the
33+
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
34+
non-blocking. By default, CPU.
2435
"""
2536

2637
def reset(self) -> None:

ignite/contrib/metrics/regression/mean_absolute_relative_error.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ class MeanAbsoluteRelativeError(_BaseRegression):
2121
2222
__ https://arxiv.org/ftp/arxiv/papers/1809/1809.03006.pdf
2323
24+
Parameters are inherited from ``Metric.__init__``.
25+
26+
Args:
27+
output_transform: a callable that is used to transform the
28+
:class:`~ignite.engine.engine.Engine`'s ``process_function``'s output into the
29+
form expected by the metric. This can be useful if, for example, you have a multi-output model and
30+
you want to compute the metric with respect to one of the outputs.
31+
By default, metrics require the output as ``(y_pred, y)`` or ``{'y_pred': y_pred, 'y': y}``.
32+
device: specifies which device updates are accumulated on. Setting the
33+
metric's device to be the same as your ``update`` arguments ensures the ``update`` method is
34+
non-blocking. By default, CPU.
2435
"""
2536

2637
def reset(self) -> None:

0 commit comments

Comments
 (0)