الانتقال إلى المحتوى
Machine Learningتقييم الموديلات· 6 دقائق للقراءة

R², MAE or RMSE? What Each Regression Metric Actually Tells You

R² compares your errors with the target's spread, so it isn't a share of correct predictions. MAE and RMSE say how far off you are, in real units.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

A delivery app predicts how long each order will take. The evaluation report shows an R² of 0.915, the release note calls the model "91.5% accurate", and the app starts promising arrival times within 5 minutes. Support tickets follow: about 3 orders in 10 miss that window. A month later the team checks the model on short downtown trips, sees an R² of 0.09 and concludes it doesn't work there. Its errors downtown are almost the same as everywhere else.

The common misconception

Many developers read R² as an accuracy percentage for regression: 0.915 means 91.5% of the predictions are right, and a high R² means the predictions are close enough to use. It's easy to see why:

  • It usually lands between 0 and 1, like a percentage, and reports often print it as one.
  • It's the default: score on every scikit-learn regressor returns R², so it's the first number people see.
  • On a single test set, a higher R² really does mean smaller squared errors, so it works for ranking models.

The half-truth: R² is a fair way to compare models on the same data. But it measures how much better the model is than predicting the average, not how close its predictions are to the truth.

What actually happens

Regression has no "correct" prediction to count. A forecast of 41 minutes for a 43-minute trip is neither right nor wrong, only off by 2 minutes. Every regression metric is a different summary of those gaps.

R² compares your errors with the average's errors

is 1 minus the model's squared errors divided by the squared errors of always predicting the mean of the test targets. The scikit-learn reference spells out the scale: 1.0 is perfect, a constant model that predicts the average gets 0.0, and the score can be negative because a model can be arbitrarily worse than that. So 0.915 says the model's squared error is 8.5% of the average's. It says nothing about how many predictions are close.

The same errors, a different R²

The denominator is the spread of the target in whatever data you score. Across all trips, from 1 to 30 km, delivery times vary a lot, so the average is a terrible guess and beating it is easy. Among trips under 5 km, times are similar, the average is already decent, and the same model has little left to beat.

Python
import numpy as npfrom sklearn.linear_model import LinearRegressionfrom sklearn.metrics import r2_scorefrom sklearn.model_selection import train_test_splitrng = np.random.default_rng(0)km = rng.uniform(1, 30, size=(5000, 1))  # delivery distancejam = 30 * (rng.random(5000) < 0.05)  # 5% of orders lose 30 minutesminutes = 8 + 3 * km[:, 0] + rng.normal(0, 4, 5000) + jamX_tr, X_te, y_tr, y_te = train_test_split(km, minutes, random_state=0)pred = LinearRegression().fit(X_tr, y_tr).predict(X_te)print(f"R2 {r2_score(y_te, pred):.3f}")# R2 0.915# "The model is 91.5% accurate"

The "91.5% accurate" model lands within 5 minutes on 70% of orders. On short trips its R² collapses from 0.92 to 0.09, yet its average error only moves from 4.8 to 5.3 minutes. The model didn't break downtown; the yardstick changed. scikit-learn's guide says it directly: because the target's variance depends on the dataset, R² may not be meaningfully comparable across different datasets. That includes two segments of your own data.

MAE and RMSE speak in minutes

is the average size of the errors: on a typical order, the estimate is 4.8 minutes off. squares the errors, averages them and takes the square root, so it's in minutes too, but big misses weigh more. Google's Machine Learning Crash Course puts the difference this way: MAE represents the average prediction error, while RMSE represents the spread of the errors and is more skewed by larger errors. Here RMSE is 7.8 against an MAE of 4.8, because 5% of orders lose 30 minutes in a jam. A wide gap between the two is a signal in itself: a few large misses are driving the error.

The baseline puts both in context. Always predicting the average trip time is off by 22.9 minutes on a typical order; the model cuts that to 4.8. That's the comparison R² summarizes, in a unit a product manager can use.

MetricAnswersUnitsWatch out for
R²How much better than predicting the mean?None, at most 1Changes with the target's spread; can be negative
MAEHow far off is a typical prediction?Target unitsTreats one 30-minute miss like six 5-minute misses
RMSEHow big are errors, with large misses weighted more?Target unitsA few big errors can dominate it
Share within toleranceHow often are we close enough?% of predictionsYou have to choose the tolerance

How to apply it in your project

  1. Start from a baselineScore DummyRegressor, which predicts the training mean, with MAE. Every model should be judged by how far below it lands.
  2. Report errors in the target's unitsPut MAE, and RMSE when large misses matter, next to R² in every report.
  3. Measure the tolerance directlyIf the business has a tolerance, such as 5 minutes or 10% of the price, report the share of predictions inside it.
  4. Compare R² only on the same test setUse it to rank models scored on identical data, never to compare segments or datasets.
  5. Break errors down by segmentLook at MAE per region, price band or customer type to find where the model really struggles.

Key takeaways

  • R² measures improvement over predicting the mean, not the share of correct predictions: 0.915 came with only 70% of orders within 5 minutes.
  • It depends on the target's spread: the same model scored 0.92 overall and 0.09 on short trips, with MAE 4.8 and 5.3.
  • MAE is the typical error; RMSE weighs big misses more, so a wide gap between them means a few large errors.
  • Pick the metric from what errors cost, report it in the target's units, and compare it with a baseline.

📚 المصادر

  1. Metrics and scoring: quantifying the quality of predictions — scikit-learn User Guide
  2. r2_score — scikit-learn API Reference
  3. Linear regression: Loss — Google Machine Learning Crash Course

التعليقات (0)