Can't import load_metric from datasets

Hi. I’m trying to follow this tutorial: Getting Started with Sentiment Analysis using Python (huggingface.co)

When running this line: from datasets import load_metric

I get an import error. “load_metric” isn’t found.

Any thoughts?

3 Likes

Support for load_metric has been removed in datasets@3.0.0, see Release 3.0.0 · huggingface/datasets · GitHub.

You now have to use the evaluate library: 🤗 Evaluate

4 Likes

Thanks! I’ll look into that!

Try the following:

pip install evaluate

import evaluate

metric = evaluate.load(“accuracy”)

8 Likes

@Whenzi This is great, thanks! I got my code working with your two lines and the following within the compute_metrics function

    # load_accuracy = load_metric("accuracy")
    # load_f1 = load_metric("f1")
    load_accuracy = evaluate.load("accuracy")
    load_f1 = evaluate.load("f1")
3 Likes