MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Natural Language Processing (NLP) in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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)]
Edit dan Jalankan Kode