How to create custom ClassLabels?

Hi! Use map to map the column to the new range and specify features to perform the cast:

features = dataset.features.copy()
features["basic_sentiment"] = ClassLabel(names=["negative", "neutral", "positive"])
def adjust_labels(batch):
    batch["basic_sentiment"] = [sentiment + 1 for sentiment in batch["basic_sentiment"]]
    return batch
dataset = dataset.map(adjust_labels, batched=True, features=features)
4 Likes