espnet3.systems.esp2_cls.src.scoring_utils.supported_classes
Less than 1 minute
espnet3.systems.esp2_cls.src.scoring_utils.supported_classes
espnet3.systems.esp2_cls.src.scoring_utils.supported_classes(target: ndarray, classes: Sequence[str]) → Tuple[ndarray, List[str]]
Select the class columns that have at least one positive reference.
espnet2’s cls_score.py scores empty classes as 0.0 and averages them in, which drags the macro mean down. Skipping them keeps the mean meaningful on label sets that a corpus does not fully cover.
- Parameters:
- target – Multi-hot target matrix of shape
(n_utterances, n_classes). - classes – Class labels in score-vector order.
- target – Multi-hot target matrix of shape
- Returns: Indices of the kept columns and their labels.
- Return type: Tuple[np.ndarray, List[str]]
- Raises:ValueError – If no class has a positive reference.
Example
neutral never appears in the references, so it is left out and the caller averages over the remaining two columns.
>>> target = np.array([[0.0, 1.0, 0.0], [0.0, 1.0, 1.0]])
>>> supported_classes(target, ["neutral", "joy", "anger"])
(array([1, 2]), ['joy', 'anger'])