Hi! You are getting this error most likely because the label training
is not specified as a label in the names
list of the ClassLabel
feature. To avoid this error, I suggest you use class_encode_column
instead, which will automatically find all the unique string values in the column:
from datasets import Dataset
dataset = Dataset.from_pandas(df)
dataset = dataset.class_encode_column("Label")