Appearance
relai.metrics package
Submodules
relai.metrics.metrics module
class relai.metrics.metrics.Confidence(reduction=None)
Bases: RELAIMetric
Calculates the confidence of the target class for each sample.
- Parameters:reduction (str , optional) – Specifies the reduction to apply to the confidence values. Can be one of [None, ‘mean’, ‘sum’]. Defaults to None.
reduction
The reduction method to apply to the confidence values.
- Type: str
forward(prediction, target)
Calculates the confidence values for the target class for each sample.
Example usage: : confidence_metric = Confidence(reduction=’mean’) confidence = confidence_metric(prediction, target)
forward(prediction, target)
class relai.metrics.metrics.Hits(reduction=None)
Bases: RELAIMetric
Hits metric calculates the accuracy of the predictions by comparing them with the target labels.
- Parameters:reduction (str , optional) – Specifies the reduction method for the metric. Can be one of [None, “mean”, “sum”]. Defaults to None.
reduction
The reduction method for the metric.
- Type: str
forward(prediction, target)
Calculates the hits metric by comparing the predictions with the target labels.
Example usage: : hits_metric = Hits(reduction=”mean”) accuracy = hits_metric(predictions, targets)
forward(prediction, target)
class relai.metrics.metrics.RELAIMetric(*args, **kwargs)
Bases: object
Base class for RELAI metrics.
forward(prediction, target)
relai.metrics.metrics.dice(true_positive: int64, false_positive: int64, false_negative: int64)
Compute dice metric.
- Parameters:
- true_positive (numpy.int64) – number of true positives.
- false_positive (numpy.int64) – number of false positives.
- false_negative (numpy.int64) – number of false negatives.
- Returns: dice metric.
- Return type: numpy.int64
relai.metrics.metrics.dice_segmentation(prediction: ndarray, target: ndarray, cls: int)
Computes dice similarity coefficient of predicted segmentation mask and target or ground truth segmentation mask.
- Parameters:
- prediction (numpy.ndarray) – a numpy array representing the segmentation mask.
- target (numpy.ndarray) – a numpy array representing the ground truth mask.
- cls – class to be considered.
relai.metrics.metrics.false_negative_segmentation(prediction: ndarray, target: ndarray, cls: int)
Computes the number of false negative pixels in the prediction segmentation mask.
- Parameters:
- prediction (numpy.ndarray) – a numpy array representing the segmentation mask.
- target (numpy.ndarray) – a numpy array representing the ground truth mask.
- cls (int) – class to be considered.
- Returns: number of false negative pixels.
- Return type: numpy.int64
relai.metrics.metrics.false_positive_segmentation(prediction: ndarray, target: ndarray, cls: int)
Computes the number of false positive pixels in the prediction segmentation mask.
- Parameters:
- prediction (numpy.ndarray) – a numpy array representing the segmentation mask.
- target (numpy.ndarray) – a numpy array representing the ground truth mask.
- cls (int) – class to be considered.
- Returns: number of false positive pixels.
- Return type: numpy.int64
relai.metrics.metrics.iou(true_positive: int64, false_positive: int64, false_negative: int64)
Compute iou metric.
- Parameters:
- true_positive (numpy.int64) – number of true positives.
- false_positive (numpy.int64) – number of false positives.
- false_negative (numpy.int64) – number of false negatives.
- Returns: iou metric.
- Return type: numpy.int64
relai.metrics.metrics.iou_segmentation(prediction: ndarray, target: ndarray, cls: int)
Computes intersection over union (or jaccard) metric for predicted segmentation mask and target segmentation
- Parameters:
- prediction (numpy.ndarray) – a numpy array representing the segmentation mask.
- target (numpy.ndarray) – a numpy array representing the ground truth mask.
- cls – class to be considered.
relai.metrics.metrics.precision(true_positive: int64, false_positive: int64)
Compute precision metric.
- Parameters:
- true_positive (numpy.int64) – number of true positives.
- false_positive (numpy.int64) – number of false positives.
- Returns: precision metric.
- Return type: numpy.int64
relai.metrics.metrics.precision_segmentation(prediction: ndarray, target: ndarray, cls: int)
Computes the precision between predicted segmentation mask and target segmentation mask.
- Parameters:
- prediction (numpy.ndarray) – a numpy array representing the segmentation mask.
- target (numpy.ndarray) – a numpy array representing the ground truth mask.
- cls (int) – class to be considered.
- Returns: segmentation precision metric.
- Return type: numpy.float64
relai.metrics.metrics.true_negative_segmentation(prediction: ndarray, target: ndarray, cls: int)
Computes the number of true negative pixels in the prediction segmentation mask.
- Parameters:
- prediction (numpy.ndarray) – a numpy array representing the segmentation mask.
- target (numpy.ndarray) – a numpy array representing the ground truth mask.
- cls (int) – class to be considered.
- Returns: number of true negative pixels.
- Return type: numpy.int64
relai.metrics.metrics.true_positive_segmentation(prediction: ndarray, target: ndarray, cls: int)
Computes the number of true positive pixels in the prediction segmentation mask.
- Parameters:
- prediction (numpy.ndarray) – a numpy array representing the segmentation mask.
- target (numpy.ndarray) – a numpy array representing the ground truth mask.
- cls (int) – class to be considered.
- Returns: number of true positive pixels.
- Return type: numpy.int64
relai.metrics.statistics module
relai.metrics.statistics.compute_significance(bottom_hits, top_hits)
Computes significance of difference between bottom_preds and top_preds :param bottom_hits: predictions==labels for bottom fraction of dataset (either 0 or 1) :param top_hits: predictions==labels for top fraction of dataset (either 0 or 1)
relai.metrics.statistics.compute_significance2(top_p, top_len, bottom_p, bottom_len)
Computes significance of difference between bottom_preds and top_preds :param top_p: top value :param top_len: length of top :param bottom_p: bottom value :param bottom_len: length of bottom