Precision and Recall metrics
BinaryPrecision
Bases: BinaryFBetaScore
Computes precision on binary structures.
Mirrors BinaryF1Score. Each field of y_true and y_pred should be
a boolean or a float in [0, 1]; floats are thresholded against
threshold. Per-field precision is TP / (TP + FP), aggregated via
average.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
average
|
str
|
One of |
None
|
threshold
|
float
|
Threshold for deciding whether a float value is
|
0.5
|
name
|
str
|
(Optional) string name of the metric instance. |
'binary_precision'
|
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
BinaryRecall
Bases: BinaryFBetaScore
Computes recall on binary structures.
Mirrors BinaryF1Score. Per-field recall is TP / (TP + FN),
aggregated via average.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
average
|
str
|
One of |
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
CategoricalPrecision
Bases: CategoricalFBetaScore
Computes precision 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: precision} dict for average=None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
average
|
str
|
One of |
None
|
labels
|
list
|
(Optional) Explicit list of label names to track. |
None
|
name
|
str
|
(Optional) string name of the metric instance. |
'categorical_precision'
|
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
CategoricalRecall
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
average
|
str
|
One of |
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
Precision
Bases: FBetaScore
Computes token-level precision for LM string outputs.
Formula (per field, SQuAD-style multiset over normalized tokens):
Mirrors F1Score: tokenization, masking and average modes behave
identically — only the result formula differs. Use this when you want
to report precision as a separate signal alongside Recall and
F1Score.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
average
|
str
|
Type of averaging across per-field results.
One of |
None
|
name
|
str
|
(Optional) string name of the metric instance. |
'precision'
|
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; fields whose names match
are kept (combined with |
None
|
out_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are dropped (combined with |
None
|
Source code in synalinks/src/metrics/precision_recall_metrics.py
Recall
Bases: FBetaScore
Computes token-level recall for LM string outputs.
Formula (per field, SQuAD-style multiset over normalized tokens):
Mirrors F1Score: tokenization, masking and average modes behave
identically — only the result formula differs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
average
|
str
|
Type of averaging across per-field results.
One of |
None
|
name
|
str
|
(Optional) string name of the metric instance. |
'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; fields whose names match
are kept (combined with |
None
|
out_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are dropped (combined with |
None
|