torchtraining.metrics.classification.binary¶
-
class
torchtraining.metrics.classification.binary.
Accuracy
(threshold: float = 0.0, reduction=<built-in method mean of type object>)[source]¶ Calculate accuracy score between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
reduction (Callable(torch.Tensor) -> Any, optional) – One argument callable getting
torch.Tensor
and returning argument after specified reduction. Default:torch.mean
(mean across batch, user can usetorchtraining.savers.Mean
to get mean across iterations/epochs).
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
If
reduction
is left as default mean is taken and single value returned. Otherwise whateverreduction
returns.- Return type
-
class
torchtraining.metrics.classification.binary.
BalancedAccuracy
(threshold: float = 0.0)[source]¶ Critical success index between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
ConfusionMatrix
(threshold: float = 0.0, reduction=<built-in method sum of type object>)[source]¶ Confusion matrix between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
reduction (Callable, optional) – One argument callable getting
torch.Tensor
and returningtorch.Tensor
. Default:torch.sum
(sum of all elements, user can usetorchtraining.savers.Sum
to get sum across iterations/epochs).
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
If
reduction
is left as default sum is taken and single value returned. Otherwise whateverreduction
returns.- Return type
-
class
torchtraining.metrics.classification.binary.
CriticalSuccessIndex
(threshold: float = 0.0)[source]¶ Critical success index between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
F1
(threshold: float = 0.0)[source]¶ F1 score between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
FBeta
(beta: float, threshold: float = 0.0)[source]¶ Get f-beta score between
outputs
andtargets
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
beta (float) – Beta coefficient of
f-beta
score.threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).
- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
FalseDiscoveryRate
(threshold: float = 0.0)[source]¶ False discovery rate between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
FalseNegative
(threshold: float = 0.0, reduction=<built-in method sum of type object>)[source]¶ Number of false negatives between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
reduction (Callable, optional) – One argument callable getting
torch.Tensor
and returningtorch.Tensor
. Default:torch.sum
(sum of all elements, user can usetorchtraining.savers.Sum
to get sum across iterations/epochs).
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
If
reduction
is left as default sum is taken and single value returned. Otherwise whateverreduction
returns.- Return type
-
class
torchtraining.metrics.classification.binary.
FalseNegativeRate
(threshold: float = 0.0)[source]¶ False negative rate between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
FalseOmissionRate
(threshold: float = 0.0)[source]¶ False omission rate between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
FalsePositive
(threshold: float = 0.0, reduction=<built-in method sum of type object>)[source]¶ Number of false positives between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
reduction (Callable, optional) – One argument callable getting
torch.Tensor
and returningtorch.Tensor
. Default:torch.sum
(sum of all elements, user can usetorchtraining.savers.Sum
to get sum across iterations/epochs).
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
If
reduction
is left as default sum is taken and single value returned. Otherwise whateverreduction
returns.- Return type
-
class
torchtraining.metrics.classification.binary.
FalsePositiveRate
(threshold: float = 0.0)[source]¶ False positive rate between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
Jaccard
(threshold: float = 0.0, reduction=<built-in method mean of type object>)[source]¶ Calculate jaccard score between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
reduction (Callable(torch.Tensor) -> Any, optional) – One argument callable getting
torch.Tensor
and returning argument after specified reduction. Default:torch.mean
(mean across batch, user can usetorchtraining.savers.Mean
to get mean across iterations/epochs).
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
If
reduction
is left as default mean is taken and single value returned. Otherwise whateverreduction
returns.- Return type
-
class
torchtraining.metrics.classification.binary.
MatthewsCorrelationCoefficient
(threshold: float = 0.0)[source]¶ Matthews correlation coefficient between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
NegativePredictiveValue
(threshold: float = 0.0)[source]¶ Negative predictive value between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
Precision
(threshold: float = 0.0)[source]¶ Precision between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
Recall
(threshold: float = 0.0)[source]¶ Recall between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
Specificity
(threshold: float = 0.0)[source]¶ Specificity between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
Scalar
tensor
- Return type
-
class
torchtraining.metrics.classification.binary.
TrueNegative
(threshold: float = 0.0, reduction=<built-in method sum of type object>)[source]¶ Number of true negatives between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
reduction (Callable, optional) – One argument callable getting
torch.Tensor
and returningtorch.Tensor
. Default:torch.sum
(sum of all elements, user can usetorchtraining.savers.Sum
to get sum across iterations/epochs).
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
If
reduction
is left as default sum is taken and single value returned. Otherwise whateverreduction
returns.- Return type
-
class
torchtraining.metrics.classification.binary.
TruePositive
(threshold: float = 0.0, reduction=<built-in method sum of type object>)[source]¶ Number of true positives between
output
andtarget
.Works for both logits and probabilities of
output
.If
output
is tensor aftersigmoid
activation user should changethreshold
to0.5
for correct results (default0.0
corresponds to unnormalized probability a.k.a logits).- Parameters
threshold (float, optional) – Threshold above which prediction is considered to be positive. Default:
0.0
reduction (Callable, optional) – One argument callable getting
torch.Tensor
and returningtorch.Tensor
. Default:torch.sum
(sum of all elements, user can usetorchtraining.savers.Sum
to get sum across iterations/epochs).
-
forward
(data)[source]¶ - Parameters
data (Tuple[torch.Tensor, torch.Tensor]) – Tuple containing
outputs
from neural network andtargets
(ground truths).outputs
should be of shape and containlogits
orprobabilities
.targets
should be of shape as well and containboolean
values (or integers from set ).- Returns
If
reduction
is left as default sum is taken and single value returned. Otherwise whateverreduction
returns.- Return type