Skip to content

Commit

Permalink
Explicit mention that 1 is the positive class in docs (#1383)
Browse files Browse the repository at this point in the history
* Apply suggestions from code review

Co-authored-by: Jirka <[email protected]>
Co-authored-by: Jirka Borovec <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 4ecb62b)
  • Loading branch information
SkafteNicki authored and Borda committed Jan 30, 2023
1 parent 98cd604 commit d172f55
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/torchmetrics/classification/auroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BinaryAUROC(BinaryPrecisionRecallCurve):
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/classification/average_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class BinaryAveragePrecision(BinaryPrecisionRecallCurve):
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/classification/calibration_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class BinaryCalibrationError(Metric):
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/classification/hinge.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BinaryHingeLoss(Metric):
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/classification/precision_recall_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BinaryPrecisionRecallCurve(Metric):
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BinaryRecallAtFixedPrecision(BinaryPrecisionRecallCurve):
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/classification/roc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class BinaryROC(BinaryPrecisionRecallCurve):
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
5 changes: 2 additions & 3 deletions src/torchmetrics/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# 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.
# this is just a bypass for this module name collision with build-in one
from collections import OrderedDict
from copy import deepcopy
from typing import Any, Dict, Hashable, Iterable, List, Optional, Sequence, Tuple, Union

Expand All @@ -22,9 +24,6 @@
from torchmetrics.utilities import rank_zero_warn
from torchmetrics.utilities.data import _flatten_dict, allclose

# this is just a bypass for this module name collision with build-in one
from torchmetrics.utilities.imports import OrderedDict


class MetricCollection(ModuleDict):
"""MetricCollection class can be used to chain metrics that have the same call pattern into one single class.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/functional/classification/auroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def binary_auroc(
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def binary_average_precision(
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def binary_calibration_error(
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/functional/classification/hinge.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def binary_hinge_loss(
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def binary_precision_recall_curve(
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def binary_recall_at_fixed_precision(
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/functional/classification/roc.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def binary_roc(
observation. If preds has values outside [0,1] range we consider the input to be logits and will auto apply
sigmoid per element.
- ``target`` (int tensor): ``(N, ...)``. Target should be a tensor containing ground truth labels, and therefore
only contain {0,1} values (except if `ignore_index` is specified).
only contain {0,1} values (except if `ignore_index` is specified). The value 1 always encodes the positive class.
Additional dimension ``...`` will be flattened into the batch dimension.
Expand Down
1 change: 0 additions & 1 deletion src/torchmetrics/utilities/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Import utilities."""
import operator
from collections import OrderedDict # noqa: F401
from functools import lru_cache
from importlib import import_module
from importlib.util import find_spec
Expand Down

0 comments on commit d172f55

Please sign in to comment.