AUC¶
Module Interface¶
- class torchmetrics.AUC(reorder=False, compute_on_step=None, **kwargs)[source]
Computes Area Under the Curve (AUC) using the trapezoidal rule
Forward accepts two input tensors that should be 1D and have the same number of elements
- Parameters
reorder¶ (
bool) – AUC expects its first input to be sorted. If this is not the case, setting this argument toTruewill use a stable sorting algorithm to sort the input in descending ordercompute_on_step¶ (
Optional[bool]) –Forward only calls
update()and returns None if this is set to False.Deprecated since version v0.8: Argument has no use anymore and will be removed v0.9.
kwargs¶ (
Dict[str,Any]) – Additional keyword arguments, see Advanced metric settings for more info.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
Functional Interface¶
- torchmetrics.functional.auc(x, y, reorder=False)[source]
Computes Area Under the Curve (AUC) using the trapezoidal rule.
- Parameters
- Return type
- Returns
Tensor containing AUC score
- Raises
ValueError – If both
xandytensors are not1d.ValueError – If both
xandydon’t have the same numnber of elements.ValueError – If
xtesnsor is neither increasing nor decreasing.
Example
>>> from torchmetrics.functional import auc >>> x = torch.tensor([0, 1, 2, 3]) >>> y = torch.tensor([0, 1, 2, 2]) >>> auc(x, y) tensor(4.) >>> auc(x, y, reorder=True) tensor(4.)