Skip to content

BinaryRecall metric

Bases: BinaryFBetaScore

Computes recall on binary structures.

Mirrors BinaryF1Score. Per-field recall is TP / (TP + FN), aggregated via average.

Example:

program.compile(
    metrics=[
        synalinks.metrics.BinaryRecall(),
    ],
)

Parameters:

Name Type Description Default
average str

One of None, "micro", "macro", "weighted".

None
threshold float

Threshold for binarizing float fields.

0.5
name str

(Optional) string name of the metric instance.

'binary_recall'
in_mask list

(Optional) list of keys to keep to compute the metric.

None
out_mask list

(Optional) list of keys to remove to compute the metric.

None
in_mask_pattern str

(Optional) Regex pattern.

None
out_mask_pattern str

(Optional) Regex pattern.

None
Source code in synalinks/src/metrics/precision_recall_metrics.py
@synalinks_export("synalinks.metrics.BinaryRecall")
class BinaryRecall(BinaryFBetaScore):
    """Computes recall on binary structures.

    Mirrors `BinaryF1Score`. Per-field recall is `TP / (TP + FN)`,
    aggregated via `average`.


    Example:

    ```python
    program.compile(
        metrics=[
            synalinks.metrics.BinaryRecall(),
        ],
    )
    ```

    Args:
        average (str): One of `None`, `"micro"`, `"macro"`, `"weighted"`.
        threshold (float): Threshold for binarizing float fields.
        name (str): (Optional) string name of the metric instance.
        in_mask (list): (Optional) list of keys to keep to compute the metric.
        out_mask (list): (Optional) list of keys to remove to compute the metric.
        in_mask_pattern (str): (Optional) Regex pattern.
        out_mask_pattern (str): (Optional) Regex pattern.
    """

    def __init__(
        self,
        average=None,
        threshold=0.5,
        name="binary_recall",
        in_mask=None,
        out_mask=None,
        in_mask_pattern=None,
        out_mask_pattern=None,
    ):
        super().__init__(
            average=average,
            beta=1.0,
            threshold=threshold,
            name=name,
            in_mask=in_mask,
            out_mask=out_mask,
            in_mask_pattern=in_mask_pattern,
            out_mask_pattern=out_mask_pattern,
        )
        self._formula = "recall"

    def get_config(self):
        base_config = super().get_config()
        del base_config["beta"]
        return base_config