Precision, recall e F1
Compromessi da comprendere
Precision, recall e F1 è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento NLP Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso NLP Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Beyond One Number
To see past accuracy you split results into four buckets per class. From them come precision, recall, and F1, the metrics that matter.
The Positive Class
Pick the class you care about as positive, like spam or fraud. Precision and recall both describe how well you handle that class.
Precision: Trust the Alarms
Precision asks: of everything you flagged as positive, how many truly were? High precision means few false alarms.
Recall: Catch Them All
Recall asks: of all the real positives, how many did you catch? High recall means few misses slip through.
The Tug of War
Precision and recall usually trade off. Flag more items and recall rises but precision drops; flag fewer and the reverse happens.
Which One First?
Spam filters favor precision, since wrongly trashing real mail is costly. Cancer screens favor recall, since a missed case is far worse.
F1: One Balanced Score
The F1 score blends precision and recall into one number using their harmonic mean, rewarding models that do both well.
Why Harmonic Mean
F1 uses the harmonic mean so a model cannot fake it. If either precision or recall is near zero, F1 stays low too.
See Them in Python
scikit-learn prints all three at once with a tidy classification report you can scan per class.
from sklearn.metrics import classification_report
print(classification_report(y_true, y_pred))Get One Metric Alone
You can also pull a single metric directly when you only need F1 for the positive class.
from sklearn.metrics import f1_score
f1 = f1_score(y_true, y_pred)Pick by the Cost
No metric is best everywhere. Choose precision, recall, or F1 by the real-world cost of each mistake in your problem.
Quick Check
Match the metric to the question it answers.
Recap
Precision limits false alarms, recall limits misses, and F1 balances both. Let the cost of each error pick your metric. 📊
Domande Frequenti
La lezione «Precision, recall e F1» è gratuita?
Sì — il testo completo di «Precision, recall e F1» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso NLP Academy, passa a CoddyKit PRO. Il corso NLP Academy include 4 lezioni in totale.
Cosa imparerò in «Precision, recall e F1»?
Compromessi da comprendere Eserciti NLP Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare NLP Academy?
Non è richiesta alcuna esperienza precedente. NLP Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.
Quanto tempo richiede la lezione «Precision, recall e F1»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione NLP Academy?
Sì. Ogni lezione NLP Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Perché l'accuratezza può ingannare
- Precision, recall e F1
- Leggere la matrice di confusione
- Cross-validation nel modo corretto