hezar.metrics.seqeval module¶
- class hezar.metrics.seqeval.Seqeval(config: SeqevalConfig, **kwargs)[source]¶
Bases:
Metric
Seqeval metric for sequence labeling tasks using seqeval.
- Parameters:
config (SeqevalConfig) – Metric configuration object.
**kwargs – Extra configuration parameters passed as kwargs to update the config.
- compute(predictions=None, targets=None, suffix: bool | None = None, mode: str | None = None, sample_weight: List[int] | None = None, zero_division: str | int | None = None, n_decimals: int | None = None, output_keys=None, **kwargs)[source]¶
Computes the Seqeval scores for the given predictions against targets.
- Parameters:
predictions – Predicted labels.
targets – Ground truth labels.
suffix (bool) – Flag to indicate whether the labels have suffixes.
mode (Optional[str]) – Evaluation mode for seqeval.
sample_weight (Optional[List[int]]) – Sample weights for the seqeval metrics.
zero_division (str | int) – Strategy for zero-division, default is 0.
n_decimals (int) – Number of decimals for the final score.
output_keys (tuple) – Filter the output keys.
- Returns:
A dictionary of the metric results, with keys specified by output_keys.
- Return type:
dict
- class hezar.metrics.seqeval.SeqevalConfig(objective: str = 'maximize', output_keys: tuple = ('accuracy', 'recall', 'precision', 'f1'), n_decimals: int = 4, suffix: bool = False, mode: str | None = None, sample_weight: List[int] | None = None, zero_division: str | int = 0)[source]¶
Bases:
MetricConfig
Configuration class for Seqeval metric.
- Parameters:
name (MetricType) – The type of metric, Seqeval in this case.
output_keys (tuple) – Keys to filter the metric results for output.
suffix (bool) – Flag to indicate whether the labels have suffixes.
mode (Optional[str]) – Evaluation mode for seqeval.
sample_weight (Optional[List[int]]) – Sample weights for the seqeval metrics.
zero_division (str | int) – Strategy for zero-division, default is 0.
- mode: str | None = None¶
- name: str = 'seqeval'¶
- objective: str = 'maximize'¶
- output_keys: tuple = ('accuracy', 'recall', 'precision', 'f1')¶
- sample_weight: List[int] | None = None¶
- suffix: bool = False¶
- zero_division: str | int = 0¶