0Pricing
Data Science Academy · Lekcja

Metryki regresji: MAE, MSE, R2

Pomiar błędu predykcji wartości liczbowych

Metryki regresji: MAE, MSE, R2 to bezpłatna lekcja Data Science Academy na CoddyKit. To lekcja 1 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 Measure Error

When a model predicts numbers, you need one honest score for how far off it is. That score is an error metric, your truth-teller. 📏

The Residual Idea

Start with the residual: the gap between the true value and the predicted one. Every regression metric is just a way to summarize these gaps.

residual = y_true - y_pred

Mean Absolute Error

MAE takes the size of each error, ignores the sign, and averages them. It tells you the typical miss in the same units as your target.

from sklearn.metrics import mean_absolute_error
mean_absolute_error(y_true, y_pred)

MAE Is Easy to Explain

Because MAE stays in real units, you can say the model is off by about 5 dollars on average. Stakeholders love that plain reading.

Mean Squared Error

MSE squares each error before averaging. Squaring punishes big misses much harder, so a few large errors dominate the score.

from sklearn.metrics import mean_squared_error
mean_squared_error(y_true, y_pred)

Squaring Changes the Units

One catch: MSE is in squared units, so dollars become squared dollars. The number is hard to interpret on its own.

Root Mean Squared Error

Take the square root of MSE to get RMSE, back in normal units. It keeps the heavy penalty on big errors but reads cleanly.

rmse = mean_squared_error(y_true, y_pred) ** 0.5

MAE vs RMSE

Choose MAE when every error matters equally, and RMSE when large mistakes are especially costly and you want them penalized more.

The R-Squared Score

R2 asks a different question: what fraction of the variation in the target your model explains. Higher means a better fit.

from sklearn.metrics import r2_score
r2_score(y_true, y_pred)

Reading R-Squared

An R2 of 1.0 is perfect, 0.0 is no better than guessing the mean. It can even go negative when a model fits worse than that.

Use Them Together

No single number tells the whole story. Pair an error metric like RMSE with R2 to see both the typical miss and the overall fit.

Quick Check

Let's pin down what each regression metric really measures.

Recap

Use MAE for plain average error, RMSE to punish big misses, and R2 for fraction of variance explained. Read them together. 🎯

Często zadawane pytania

Czy lekcja „Metryki regresji: MAE, MSE, R2” jest bezpłatna?

Tak — pełny tekst „Metryki regresji: MAE, MSE, R2” 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 „Metryki regresji: MAE, MSE, R2”?

Pomiar błędu predykcji wartości liczbowych Ć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 1 z 4.

Ile czasu zajmuje lekcja „Metryki regresji: MAE, MSE, R2”?

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