Source code for iaa_od.models.c_score

from dataclasses import dataclass, field

[docs] @dataclass(slots=True, kw_only=True) class CScore: """ Represents the C-Score metric for inter-annotator agreement. Attributes: c_score (float): The computed C-Score value. per_unit_c_scores (dict[int, float]): A dictionary mapping unit IDs to their respective C-Score values. """ c_score: float per_unit_c_scores: dict[int, float] = field(default_factory=dict) def __str__(self) -> str: s: str = f"C-Score: {self.c_score:.4f}\n" s += "Per-unit C-Scores:\n" for unit_id, unit_c_score in self.per_unit_c_scores.items(): s += f" Unit {unit_id}: {unit_c_score:.4f}\n" return s
[docs] def brief(self) -> str: return f"C-Score: {self.c_score:.4f}\n"
[docs] def c_score_for_unit(self, unit_id: int) -> float: """ Retrieves the C-Score for a specific unit. Parameters: unit_id (int): The ID of the unit to retrieve the C-Score for. Returns: float: The C-Score value for the specified unit, or None if not available. """ if unit_id not in self.per_unit_c_scores: raise ValueError(f"C-Score for unit {unit_id} is not available.") return self.per_unit_c_scores[unit_id]