A residual plot helps you see how far your model's predictions deviate from actual data. Use this diagnostic tool to check if your regression model is working correctly or if it is missing underlying trends. It turns complex error patterns into simple visuals so you can quickly improve your model’s accuracy.
Understanding Your Model's Errors
Every regression model makes mistakes, and these are known as residuals—the difference between the actual observed value and the value your model predicted. By analyzing these, you can move beyond simple summary metrics to see how your model behaves across the entire dataset.
Lattice generates these plots by comparing your input columns to your model's output. By visualizing these gaps, you can determine if your model is consistently overestimating or underestimating certain groups, or if the errors are purely random noise.
Detecting Patterns and Bias
The primary use of this tool is the 'versus fitted' view. By plotting residuals against fitted values, you look for structure in the noise. If you see a clear pattern, such as a U-shape, it is a strong indicator that a linear model is not sufficient and that you may need to include more complex variables or transformations.
This view is also effective for identifying uneven error variance. If the 'spread' of your residuals grows wider as your predicted values increase, it suggests that your model is less reliable in certain ranges, helping you decide where to refine your data collection or feature engineering.
Checking Data Distribution
Beyond patterns, it is important to understand the distribution of your errors. The histogram view allows you to see if your residuals are centered around zero and follow a normal distribution.
When residuals are normally distributed, it confirms that your model is balanced and that your standard error estimates are likely trustworthy. If the histogram looks skewed or has heavy tails, it may indicate that your data contains outliers or that a different modeling approach is required.
Simple Diagnostic Workflow
Lattice simplifies this diagnostic process by handling the math automatically. Whether you have pre-calculated residuals or need the platform to compute them from your dataset, the tool ensures consistency by performing the required calculations on your behalf.
Because this tool is deterministic, you get the same clear, visual diagnostics every time. It allows you to iterate on your models faster, ensuring you identify potential issues before relying on your results for critical business decisions.
1 · Intent → method
An LLM picks plot_residual from a fixed catalog.
2 · Method → numbers
Deterministic Python engine runs the math. Same input → same output.
3 · Numbers → plain language
A second LLM translates the result into your domain’s vocabulary.
What does a residual plot tell me about my model?
It shows the gap between predicted and actual values. If the points are randomly scattered around zero, your model is performing well. If you see specific shapes or curves, it suggests your model might be missing important information in your data.
Why would I use this instead of just looking at R-squared?
R-squared measures how well your model fits, but a residual plot reveals if the model is biased or flawed. Even with a high score, hidden patterns in your residuals can indicate that your model is failing to capture the true behavior of your data.
Tool input schema
Schema for plot_residual not exported yet (run pnpm export:registry).