deepml.metrics package
Submodules
deepml.metrics.classification module
- class deepml.metrics.classification.Binarizer(threshold=0.5)[source]
Bases:
Module- __init__(threshold=0.5)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(output)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class deepml.metrics.classification.Accuracy(threshold=0.5)[source]
Bases:
Module- __init__(threshold=0.5)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(output, target)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class deepml.metrics.classification.Precision(threshold=0.5, epsilon=1e-06)[source]
Bases:
Module- __init__(threshold=0.5, epsilon=1e-06)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(output, target)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class deepml.metrics.classification.Recall(threshold=0.5, epsilon=1e-06)[source]
Bases:
Module- __init__(threshold=0.5, epsilon=1e-06)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(output, target)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class deepml.metrics.classification.FScore(beta=1.0, threshold=0.5, epsilon=1e-06)[source]
Bases:
Module- __init__(beta=1.0, threshold=0.5, epsilon=1e-06)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(output, target)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class deepml.metrics.classification.MCC(threshold=0.5, epsilon=1e-06)[source]
Bases:
ModuleMatthews correlation coefficient The metric useful for imbalanced dataset.
Check more info at https://en.wikipedia.org/wiki/Matthews_correlation_coefficient
- __init__(threshold=0.5, epsilon=1e-06)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(output, target)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
deepml.metrics.commons module
deepml.metrics.segmentation module
- class deepml.metrics.segmentation.ToClassIndex(mode='binary', threshold=None, activation=None)[source]
Bases:
Module
- class deepml.metrics.segmentation.SegmentationMetric(mode='binary', reduction='macro-imagewise', activation=None, ignore_index=None, threshold=None, num_classes=None, class_weights=None, target_class_index=None, zero_division=1.0, callable=None)[source]
- class deepml.metrics.segmentation.Precision(mode='binary', reduction='macro-imagewise', activation=None, ignore_index=None, threshold=None, num_classes=None, class_weights=None, target_class_index=None, zero_division=1.0, callable=None)[source]
Bases:
SegmentationMetricComputes the precision metric for segmentation.
- Parameters:
mode (str) – The mode of the metric, either ‘binary’ or ‘multiclass’ or ‘multilabel’. Default is ‘Binary’.
reduction (str, optional) – Define how to aggregate metric between classes and images: ‘micro’, ‘macro’, ‘weighted’, ‘micro-imagewise’, ‘macro-imagewise’, ‘weighted-imagewise’. Default is “macro-imagewise”. Reference link: https://smp.readthedocs.io/en/latest/metrics.html#segmentation_models_pytorch.metrics.functional.precision
activation (torch.nn.Module, optional) – An activation function to apply to the output of the model. Default is None.
ignore_index (int, optional) – Specifies a target value that is ignored and does not contribute to the metric calculation. Default is None.
threshold (float, optional) – Threshold value for binarizing the output. Default is None.
num_classes (int, optional) – Number of classes for the metric calculation. Default is None.
class_weights (torch.Tensor, optional) – A manual rescaling weight given to each class. Default is None.
zero_division (float) – Value to return when there is a zero division. Default is 1.0.
target_class_index (int, optional) – The class index for which to compute the precision. Default is None.
callabe (callable, optional) – A callable function to apply to the output and target before metric calculation. Default is None.
- class deepml.metrics.segmentation.Recall(mode='binary', reduction='macro-imagewise', activation=None, ignore_index=None, threshold=None, num_classes=None, class_weights=None, target_class_index=None, zero_division=1.0, callable=None)[source]
Bases:
SegmentationMetricComputes the recall metric for segmentation tasks.
- Parameters:
mode (str) – The mode of the metric, either ‘binary’ or ‘multiclass’ or ‘multilabel’. Default is ‘Binary’.
reduction (str, optional) – Define how to aggregate metric between classes and images: ‘micro’, ‘macro’, ‘weighted’, ‘micro-imagewise’, ‘macro-imagewise’, ‘weighted-imagewise’. Default is ‘macro-imagewise’. Reference link: https://smp.readthedocs.io/en/latest/metrics.html#segmentation_models_pytorch.metrics.functional.precision
activation (torch.nn.Module, optional) – An activation function to apply to the output of the model. Default is None.
ignore_index (int, optional) – Specifies a target value that is ignored and does not contribute to the metric calculation. Default is None.
threshold (float, optional) – Threshold value for binarizing the output. Default is None.
num_classes (int, optional) – Number of classes for the metric calculation. Default is None.
class_weights (torch.Tensor, optional) – A manual rescaling weight given to each class. Default is None.
target_class_index (int, optional) – The class index for which to compute the recall. Default is None.
zero_division (float) – Value to return when there is a zero division. Default is 1.0.
callable (callable, optional) – A callable function to apply to the output and target before metric calculation. Default is None.
- class deepml.metrics.segmentation.F1Score(mode='binary', reduction='macro-imagewise', activation=None, ignore_index=None, threshold=None, num_classes=None, class_weights=None, target_class_index=None, zero_division=1.0, callable=None)[source]
Bases:
SegmentationMetricComputes the f1 metric for segmentation tasks.
- Parameters:
mode (str) – The mode of the metric, either ‘binary’ or ‘multiclass’ or ‘multilabel’. Default is ‘Binary’.
reduction (str, optional) – Define how to aggregate metric between classes and images: ‘micro’, ‘macro’, ‘weighted’. Default is None.
activation (torch.nn.Module, optional) – An activation function to apply to the output of the model. Default is None.
ignore_index (int, optional) – Specifies a target value that is ignored and does not contribute to the metric calculation. Default is None.
threshold (float, optional) – Threshold value for binarizing the output. Default is None.
num_classes (int, optional) – Number of classes for the metric calculation. Default is None.
class_weights (torch.Tensor, optional) – A manual rescaling weight given to each class. Default is None.
target_class_index (int, optional) – The class index for which to compute the f1 score. Default is None.
zero_division (float) – Value to return when there is a zero division. Default is 1.0.
callable (callable, optional) – A callable function to apply to the output and target before metric calculation. Default is None.
- class deepml.metrics.segmentation.Accuracy(mode='binary', reduction='macro-imagewise', activation=None, ignore_index=None, threshold=None, num_classes=None, class_weights=None, target_class_index=None, zero_division=1.0, callable=None)[source]
Bases:
SegmentationMetricComputes the accuracy metric for segmentation tasks.
- Parameters:
mode (str) – The mode of the metric, either ‘binary’ or ‘multiclass’ or ‘multilabel’. Default is ‘binary’.
reduction (str, optional) – Define how to aggregate metric between classes and images: ‘micro’, ‘macro’, ‘weighted’, ‘micro-imagewise’, ‘macro-imagewise’, ‘weighted-imagewise’. Default is “macro-imagewise”. Reference link: https://smp.readthedocs.io/en/latest/metrics.html
activation (torch.nn.Module, optional) – An activation function to apply to the output of the model. Default is None.
ignore_index (int, optional) – Specifies a target value that is ignored and does not contribute to the metric calculation. Default is None.
threshold (float, optional) – Threshold value for binarizing the output. Default is None.
num_classes (int, optional) – Number of classes for the metric calculation. Default is None.
class_weights (torch.Tensor, optional) – A manual rescaling weight given to each class. Default is None.
target_class_index (int, optional) – The class index for which to compute the accuracy. Default is None.
zero_division (float) – Value to return when there is a zero division. Default is 1.0.
callable (callable, optional) – A callable function to apply to the output and target before metric calculation. Default is None.
- class deepml.metrics.segmentation.IoUScore(mode='binary', reduction='macro-imagewise', activation=None, ignore_index=None, threshold=None, num_classes=None, class_weights=None, target_class_index=None, zero_division=1.0, callable=None)[source]
Bases:
SegmentationMetricComputes the jaccard index metric for segmentation.
- Parameters:
mode (str) – The mode of the metric, either ‘binary’ or ‘multiclass’ or ‘multilabel’. Default is ‘Binary’.
reduction (str, optional) – Define how to aggregate metric between classes and images: ‘micro’, ‘macro’, ‘weighted’. Default is None.
activation (torch.nn.Module, optional) – An activation function to apply to the output of the model. Default is None.
ignore_index (int, optional) – Specifies a target value that is ignored and does not contribute to the metric calculation. Default is None.
threshold (float, optional) – Threshold value for binarizing the output. Default is None.
num_classes (int, optional) – Number of classes for the metric calculation. Default is None.
class_weights (torch.Tensor, optional) – A manual rescaling weight given to each class. Default is None.
zero_division (float) – Value to return when there is a zero division. Default is 1.0.
target_class_index (int, optional) – The class index for which to compute the precision. Default is None.
callable (callable, optional) – A callable function to apply to the output and target before metric calculation. Default is None.