vak.common.labels.to_map#
- vak.common.labels.to_map(labelset: set, map_unlabeled: bool = True) dict [source]#
Convert set of labels to dict mapping those labels to a series of consecutive integers from 0 to n inclusive, where n is the number of labels in the set.
This ‘labelmap’ is used when mapping labels from annotations of a vocalization into a label for every time bin in a spectrogram of that vocalization.
If
map_unlabeled
is True, then the label ‘unlabeled’ will be added to labelset, and will map to 0, so the total number of classes is n + 1.- Parameters:
labelset (set) – Set of labels used to annotate a dataset.
map_unlabeled (bool) – If True, include key ‘unlabeled’ in mapping. Any time bins in a spectrogram that do not have a label associated with them, e.g. a silent gap between vocalizations, will be assigned the integer that the ‘unlabeled’ key maps to.
- Returns:
labelmap – Maps labels to integers.
- Return type: