Skip to content

Commit 5390256

Browse files
feat: add residual-plot specification
Manual creation after spec-create workflow failure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1fe9e2c commit 5390256

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# residual-plot: Residual Plot
2+
3+
## Description
4+
5+
A residual plot displays the difference between observed and predicted values (residuals) against fitted values or an independent variable in regression analysis. This diagnostic visualization helps identify violations of regression assumptions including non-linearity, heteroscedasticity (non-constant variance), and outliers. A well-fitting model shows residuals randomly scattered around zero with no discernible pattern.
6+
7+
## Applications
8+
9+
- Validating linear regression model assumptions by checking for random residual distribution
10+
- Detecting non-linear relationships that suggest the need for polynomial or transformed features
11+
- Identifying heteroscedasticity where prediction errors vary with fitted values
12+
- Locating influential outliers and leverage points that may distort model coefficients
13+
- Comparing model fit quality across different regression specifications
14+
15+
## Data
16+
17+
- `y_true` (numeric array) - Observed/actual target values
18+
- `y_pred` (numeric array) - Predicted values from regression model
19+
- Residuals calculated as: `residuals = y_true - y_pred`
20+
- Size: 50-1000 observations typical for regression diagnostics
21+
- Example: Linear regression predictions from sklearn with residuals
22+
23+
## Notes
24+
25+
- Include a horizontal reference line at y=0 representing perfect predictions
26+
- Plot residuals on y-axis against fitted values on x-axis (standard residual plot)
27+
- Use alpha transparency for overlapping points when sample size is large
28+
- Optional: Add LOWESS or kernel smoothing line to detect non-linear patterns in residuals
29+
- Consider adding horizontal bands at ±2 standard deviations to identify potential outliers
30+
- Color outliers differently if residuals exceed threshold (e.g., 2 or 3 standard deviations)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Specification-level metadata for residual-plot
2+
# Auto-synced to PostgreSQL on push to main
3+
4+
spec_id: residual-plot
5+
title: Residual Plot
6+
7+
# Specification tracking
8+
created: 2025-12-26T19:35:00Z
9+
updated: null
10+
issue: 2332
11+
suggested: MarkusNeusinger
12+
13+
# Classification tags (applies to all library implementations)
14+
# See docs/concepts/tagging-system.md for detailed guidelines
15+
tags:
16+
plot_type:
17+
- scatter
18+
- residual
19+
- diagnostic
20+
data_type:
21+
- numeric
22+
- continuous
23+
- regression
24+
domain:
25+
- statistics
26+
- machine-learning
27+
- econometrics
28+
features:
29+
- basic
30+
- model-evaluation
31+
- reference-line
32+
- diagnostics

0 commit comments

Comments
 (0)