I am trying to do multiclass classification. I am following the HuggingFace sentiment analysis blog from Federico Pascual. When it came to define the metric function I just copied the code from the blog:

import numpy as np

from datasets import load_metric

def compute_metrics(eval_pred):

load_accuracy = load_metric(“accuracy”)

load_f1 = load_metric(“f1”)

logits, labels = eval_pred

predictions = np.argmax(logits, axis=-1)

accuracy = load_accuracy.compute(predictions=predictions, references=labels)[“accuracy”]

f1 = load_f1.compute(predictions=predictions, references=labels)[“f1”]

return {“accuracy”: accuracy, “f1”: f1}

When I run trainer.evaluate() I get this error:

ValueError: Target is multiclass but average=‘binary’. Please choose another average setting, one of [None, ‘micro’, ‘macro’, ‘weighted’].

Then I added the ‘average’ parameter to load_accuracy.compute() and load_f1.compute() and set it to first ‘None’ then ‘weighted’ and both led to same error:

TypeError: _compute() got an unexpected keyword argument ‘average’

You guys have any idea what’s wrong? Thanks in advance