Skip to content

CategoricalRecall metric

Bases: CategoricalFBetaScore

Computes recall on categorical (list / label) structures.

Mirrors CategoricalF1Score. Supports the optional labels= parameter: when provided, accumulation is per-label (sklearn-style) and result() returns a {label: recall} dict for average=None.

Example:

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

Parameters:

Name Type Description Default
average str

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

None
labels list

(Optional) Explicit list of label names to track.

None
name str

(Optional) string name of the metric instance.

'categorical_recall'
in_mask list

(Optional) list of keys to keep.

None
out_mask list

(Optional) list of keys to remove.

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.CategoricalRecall")
class CategoricalRecall(CategoricalFBetaScore):
    """Computes recall on categorical (list / label) structures.

    Mirrors `CategoricalF1Score`. Supports the optional `labels=` parameter:
    when provided, accumulation is per-label (sklearn-style) and
    `result()` returns a `{label: recall}` dict for `average=None`.


    Example:

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

    Args:
        average (str): One of `None`, `"micro"`, `"macro"`, `"weighted"`.
        labels (list): (Optional) Explicit list of label names to track.
        name (str): (Optional) string name of the metric instance.
        in_mask (list): (Optional) list of keys to keep.
        out_mask (list): (Optional) list of keys to remove.
        in_mask_pattern (str): (Optional) Regex pattern.
        out_mask_pattern (str): (Optional) Regex pattern.
    """

    def __init__(
        self,
        average=None,
        labels=None,
        name="categorical_recall",
        in_mask=None,
        out_mask=None,
        in_mask_pattern=None,
        out_mask_pattern=None,
    ):
        super().__init__(
            average=average,
            beta=1.0,
            labels=labels,
            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