Multi-class Using Dataset

lhoestq
Mon, 23 Aug 2021 16:20:16 +0000

Hi !

The ClassLabel feature type is for single-label multi-class classification.
For multi-label classification you can use

from datasets.features import ClassLabel, Sequence
labels_type = Sequence(ClassLabel(names=classes))

and modify your the function you pass to map to convert your list of 21 booleans to the list of True indices. For example:

[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0] → [4, 12, 18]