Notes

Residual Plots

A model can look great on a single score like RMSE and still be quietly “getting things wrong” in a systematic way. Residual plots are a simple visual check that helps you see those hidden problems by looking at the model’s errors directly.

What residual plots show
A residual is the difference between what you observed and what the model predicted: observed − predicted. A residual plot graphs these residuals against something informative—most commonly the model’s predicted values or an input feature. If the model is well-specified, residuals should look like random noise centered around zero, with no obvious structure.

Common patterns and what they mean
Residual plots are especially good at revealing assumption violations and model misspecification:

  • Curved pattern: the relationship isn’t truly linear; you may need polynomial terms, interactions, or a different model.
  • Fan/megaphone shape (spread increases with prediction): heteroscedasticity; errors grow with the target level (common in house prices).
  • Clusters or stripes: missing categorical variables, segmentation effects, or unmodeled groups.
  • Outliers: unusual points that can overly influence fitted parameters.
  • Residuals vs time showing waves: autocorrelation in time series; errors aren’t independent.

Practical example
In a house-price model, a residual plot might show small errors for inexpensive homes but large positive residuals for expensive homes. That suggests the model systematically underpredicts high-end properties—often fixed by transforming the target (e.g., log price) or adding features like neighborhood quality.

Why this matters in ML
In AI/ML workflows, residual plots complement metrics by diagnosing bias, unstable error variance, and data issues. They guide feature engineering, target transformations, and model choice (linear regression vs tree-based models). In Python, they’re commonly made with statsmodels, scikit-learn (with custom plotting), and seaborn.

Residual Plots are diagnostic graphs that display model residuals (observed minus predicted values) against fitted values, predictors, or time to assess whether a regression model’s assumptions and fit are reasonable. Random scatter around zero suggests an adequate model; patterns can indicate nonlinearity, heteroscedasticity, autocorrelation, or outliers. In ML, they help validate predictive models beyond aggregate error metrics—for example, revealing increasing error variance at higher predicted values.

Imagine you’re throwing darts at a target. Each dart lands a little away from the bullseye, and you want to see if your misses are random or if you’re consistently off in one direction. A residual plot is like a picture of those “misses” for a prediction model.

In statistics and machine learning, a residual is the difference between what the model predicted and what actually happened. A residual plot graphs these differences to check if the model is behaving sensibly. If the dots look like a random cloud around zero, that’s good. Clear patterns (curves, funnels, clusters) can signal the model is missing something important.