Residual Plot
When a regression model makes a prediction, the interesting part isn’t just the prediction—it’s how far off it was. A residual plot is a simple picture that helps you see whether those misses look like random noise or like a pattern your model failed to learn.
What it shows
A residual is the difference between the true value and the model’s prediction: residual = y − ŷ. A residual plot graphs these residuals on the vertical axis against something on the horizontal axis—commonly the predicted values (ŷ) or an input feature (like square footage). In a healthy regression fit, residuals form a roughly horizontal band centered around zero, with no obvious structure.
What patterns mean (and why you care)
- Curved pattern: the relationship is non-linear; a linear model is missing shape (try polynomial features, splines, or tree-based models).
- Funnel shape (spread grows/shrinks): heteroscedasticity; error variance changes with the target level (consider transforming the target, e.g., log, or using models robust to non-constant variance).
- Clusters/stripes: missing categorical variables or segment effects (e.g., neighborhoods in house prices).
- Outliers: a few points dominate error metrics; they can indicate data issues or rare but important cases (fraud spikes, unusual medical readings).
Practical use in a pipeline
In house price prediction, plotting residuals vs. predicted price can reveal that expensive homes have systematically larger errors—your model might need more features (renovation quality) or a log-price target. In scikit-learn, you’ll commonly compute residuals from a fitted regressor and plot them; statsmodels also offers built-in diagnostics for residual analysis.
A Residual Plot is a diagnostic chart that graphs residuals (observed minus predicted values) against fitted values or an input feature in a regression model. Random scatter around zero indicates errors consistent with model assumptions; visible patterns (trend, curvature, funnel shape, clusters) signal misspecification, nonlinearity, heteroscedasticity, outliers, or dependence. It matters because it reveals systematic error that aggregate metrics can hide and guides corrective modeling choices.
Imagine you’re throwing darts at a target. After each throw, you don’t just ask “Did I hit?”—you look at how far off you were and whether you keep missing in the same direction. A Residual Plot is like that for predictions.
In supervised learning (especially for predicting numbers like house prices), a “residual” means the gap between what the model predicted and what actually happened. A Residual Plot charts those gaps across many examples. If the dots look randomly scattered around zero, the model’s errors are mostly just noise. If you see patterns (like curves or widening spreads), it’s a clue the model is systematically missing something.