Aan de slagGa gratis aan de slag

Comparing models on labeled review data

Now that you can classify sentiment in bulk, your team wants to evaluate which model is more reliable. You'll compare two models using a larger labeled dataset of reviews and measure their accuracy.

A texts list and its true_labels are pre-loaded for you.

Deze oefening maakt deel uit van de cursus

Natural Language Processing (NLP) in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

from transformers import pipeline
from sklearn.metrics import accuracy_score
# Load sentiment analysis models
pipe_a = pipeline(task="sentiment-analysis", ____)
pipe_b = pipeline(task="sentiment-analysis", ____)

# Generate predictions
preds_a = [____ for res in pipe_a(texts)]
preds_b = [____ for res in pipe_b(texts)]
Code bewerken en uitvoeren