Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Evaluating regression models with residuals, MAE and MSE

You have a trained model and predictions for two years. This page evaluates how good those predictions actually are, using both aggregate metrics and spatial residual analysis, since either one alone can hide a genuine problem the other would catch.


1. Motivation

A single RMSE value can look perfectly reasonable while masking a specific region where the model performs poorly, exactly the kind of blind spot that matters if your project depends on accuracy in a particular area. Reading metrics and maps together is what catches this.


2. Core idea

Regression evaluation combines four numeric metrics, each answering a slightly different question about prediction quality, with visual tools, residual maps and scatter plots, that reveal where and how errors are structured, information no single number can convey on its own.


3. Workflow

A. Three-panel comparison

This produces ground truth, prediction, and residual (difference) maps side by side. valid_range filters out outlier pixels before computing metrics, keeping the evaluation fair and focused on physically plausible values. The residual panel is where spatial patterns in error become visible directly, information the metrics computed alongside it cannot show on their own.

B. Scatter plot

In an ideal model, points cluster tightly along the 1:1 line. Systematic deviation from that line, for example predictions consistently a bit lower than actual values at the high end, reveals a bias that an aggregate metric alone would not make as visually obvious.

C. The four standard metrics

D. Reading residual maps


4. Python reactivation

No new Python syntax here; this page mainly interprets the outputs of functions with the same keyword-argument calling pattern used throughout this lesson.


5. Common pitfalls


6. Mini task

Your model reports RMSE of 0.06 and R-squared of 0.82 on the 2022 training raster. The residual map shows small, scattered errors almost everywhere, except a spatially coherent patch of consistently high positive residuals along a reservoir shoreline. What would you investigate first, and why?

Sample solution

The shoreline patch is worth investigating first, since it is spatially coherent (not just noise) and represents a systematic, localized failure mode the aggregate RMSE and R-squared do not reveal on their own. A reasonable first hypothesis is that mixed water-vegetation pixels along the shoreline, or seasonal water-level changes between the imagery and NDVI reference dates, are producing values the model was not well trained to handle; checking a few of these coordinates directly against both dates’ imagery would help confirm or rule this out before deciding whether it matters for your project’s specific area of interest.


7. Key takeaways