How to create custom ClassLabels?

fogx
Thu, 13 Jan 2022 11:56:02 +0000

I would like to turn a column in my dataset into ClassLabels.
For my use case, i have a column with three values and would like to map these to the class labels.
Creating the labels and setting the column is fairly straightforward:

# "basic_sentiment holds values [-1,0,1]
feat_sentiment = ClassLabel(num_classes = 3,names=["negative", "neutral", "positive"])
dataset = dataset.cast_column("basic_sentiment", feat_sentiment)

Now ClassLabel has three labels: 0 - negative, 1 - neutral, 2-positive, while the data still has values -1 to 1.
How can i set the ClassLabels to use the labels in the columns? Or do i have to set my column to fit the labels of the ClassLabel now?
I couldn’t find an in-depth explanation on how to use this feature in huggingset dataface.