0Pricing
Data Science Academy · Lekcja

Precision, Recall i F1

Kompromis między rodzajami błędów

Precision, Recall i F1 to bezpłatna lekcja Data Science Academy na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Data Science Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Data Science Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Why Accuracy Falls Short

When one class is rare, accuracy can look great while the model misses everything that matters. You need sharper metrics like precision and recall. 🎯

Precision Defined

Precision asks: of all the cases I flagged as positive, how many were truly positive? It measures how trustworthy a yes really is.

precision = TP / (TP + FP)

When Precision Matters

High precision matters when false alarms are costly, like marking a real email as spam. You want every flag to be correct.

Recall Defined

Recall asks: of all the truly positive cases, how many did I catch? It measures how good the model is at not missing things.

recall = TP / (TP + FN)

When Recall Matters

High recall matters when misses are dangerous, like screening for a disease. Catching every real case outweighs a few false alarms.

The Tug of War

Precision and recall usually pull against each other. Flag more cases and you catch more but raise false alarms. It is a trade-off.

Enter the F1 Score

The F1 score blends precision and recall into one number using their harmonic mean, rewarding models that balance both well.

f1 = 2 * (precision * recall) / (precision + recall)

Why Harmonic Mean

The F1 uses a harmonic mean so a low score on either side drags it down. You cannot fake it by acing just one metric.

Get Them in One Call

You do not compute these by hand. The classification report prints precision, recall, and F1 for every class at once.

from sklearn.metrics import classification_report
print(classification_report(y_true, y_pred))

Pick the Metric to Optimize

Let the problem decide. Optimize recall when misses hurt, precision when false alarms hurt, and F1 when you need a balance.

Watch the Averaging

With many classes, choose how to average. Macro treats classes equally, weighted accounts for class size. The choice changes the story.

f1_score(y_true, y_pred, average='macro')

Quick Check

Let's make sure precision and recall stay straight in your mind.

Recap

Precision trusts your yes, recall catches the positives, and F1 balances both. Let the cost of each mistake guide your choice. 🎯

Często zadawane pytania

Czy lekcja „Precision, Recall i F1” jest bezpłatna?

Tak — pełny tekst „Precision, Recall i F1” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Data Science Academy, przejdź na CoddyKit PRO. Kurs Data Science Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Precision, Recall i F1”?

Kompromis między rodzajami błędów Ćwiczysz Data Science Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Data Science Academy?

Nie wymagamy żadnego doświadczenia. Data Science Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.

Ile czasu zajmuje lekcja „Precision, Recall i F1”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Data Science Academy?

Tak. Każda lekcja Data Science Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Metryki regresji: MAE, MSE, R2
  2. Macierz pomyłek bez tajemnic
  3. Precision, Recall i F1
  4. ROC, AUC i progi
← Powrót do Data Science Academy