tsseg.metrics.scored_islands#

scored_islands(labels, unscored=(-1,))[source]#

Maximal runs of samples whose label is not in unscored.

Parameters:
  • labels (Sequence[int] | ndarray) – Reference label of every time point.

  • unscored (Iterable[int]) – Labels that are not scored: missing truth, unknown codes, and, for state detection, classes such as a background.

Returns:

The half-open intervals (a, b) of the scored samples, sorted. Pass them as scored_intervals to a metric.

Return type:

list[tuple[int, int]]

Examples

>>> scored_islands([0, 0, -1, -1, 1, 1, 2])
[(0, 2), (4, 7)]