linear-regression
Skill0 starsChanged 6 months agoMITView on GitHub
Fits, evaluates, and interprets linear regression for continuous outcomes (revenue, session time, NPS scores) with residual diagnostics and assumption checks. Use when the user mentions linear regression, OLS, continuous outcome, "predict <numeric KPI>", coefficient interpretation, R-squared, or regression diagnostics.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- WindcleaverDev/regkittheir own version, first seen Jun 13, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- WindcleaverDev/regkit★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- ab-test-analysisSkill
- ab-test-designSkill
- causal-inferenceSkill
- cohort-analysisSkill
- data-quality-auditSkill
- funnel-analysisSkill
- logistic-regressionSkill
- metric-definitionSkill
- modular-sql-ctesSkill
- sql-correctness-reviewSkill
- sql-query-reviewSkill
- stakeholder-readoutSkill
- survival-analysisSkill
- warehouse-query-optimizationSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use for continuous outcome prediction or explanation where interpretability matters.
- Distinctive: line 47
Keep and use robust regression
- Distinctive: line 60
Independence: no autocorrelation (for time-series)
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Linear Regression
When to use this skill
Use for continuous outcome prediction or explanation where interpretability matters. Triggers:
- "Predict revenue / session time / NPS"
- "What drives
<continuous metric>?" - "Linear regression for…"
- "OLS"
- "Explain the variation in…"
For binary outcomes use logistic-regression. For time-to-event use survival-analysis. For pure prediction with non-linear effects, fit linear first as baseline, then suggest gradient boosting.
Required inputs
| Input | Why it matters |
| Continuous target | What you're predicting (numeric, ideally not heavily skewed) |
| Feature set | Predictors |
| Observation grain | Per user / per session / per geography |
| Train/test strategy | Temporal split for production, random for exploratory |
| Goal | Pure prediction, coefficient interpretation, or both? |
Workflow
- Audit the data (
data-quality-auditskill). - Inspect the target distribution.
import matplotlib.pyplot as plt df[target].hist(bins=50) df[target].describe()- Symmetric, finite variance → OK for OLS
- Heavily right-skewed (revenue, time-on-page) → consider
log(1 + target)transformation - Heavy-tailed with extreme outliers → robust regression or winsorize
- Check for outliers at p99 and p99.9. Decide:
- Cap at p99 (winsorize)
- Drop with documented justification
- Keep and use robust regression
- Verify no leakage (same checks as logistic-regression).
- Split temporally (or random for exploratory).
- Fit baseline OLS with all features. Use
statsmodelsfor coefficient inference,sklearnfor production fitting. - Check assumptions (diagnostics matter more than for logistic):
- Linearity: residuals vs predicted should look random
- Homoscedasticity: residual variance constant across predicted values
- Normality of residuals: Q-Q plot
- No multicollinearity: VIF < 5 (warn at 5-10, fail at > 10)
- Independence: no autocorrelation (for time-series)
- Evaluate on holdout:
- RMSE (in original units — interpretable to stakeholders)
- MAE (more robust to outliers)
- R² (variance explained — but easily inflated, don't worship)
- Out-of-time R² is the real test
- Interpret coefficients.
- Standardized coefficients to compare features
- Report 95% CIs (statsmodels gives these)
- Watch for sign flips when adding/removing correlated features (multicollinearity sign)
- Write the readout.
Output format
# Linear Regression: <outcome>
## Setup
- Outcome: <target> (unit: <e.g., dollars per user>)
- Distribution: mean <X>, median <Y>, p99 <Z> (transformation: <none | log(1+y) | winsorize@p99>)
- Observation unit: <user / session / geo>
- Sample: <N_train> train, <N_test> test (split: <temporal at YYYY-MM-DD | random>)
- Features: <N> features
## Performance (test set)
| Metric | Value | Notes |
|---|---|---|
| RMSE | 18.4 | Target std = 27.1 |
| MAE | 12.1 | |
| R² | 0.47 | |
| R² out-of-time | 0.42 | |
## Coefficients (top by |effect|, standardized)
| Feature | β | SE | t | 95% CI | β std | Interpretation |
|---|---|---|---|---|---|---|
| tenure_months | +1.84 | 0.12 | 15.3 | [+1.60, +2.08] | +0.41 | +1 month → +$1.84 revenue |
| has_team_plan | +24.10 | 1.42 | 16.9 | [+21.3, +26.9] | +0.38 | team plan → +$24.10 revenue |
| device_mobile_pct | -0.32 | 0.04 | -8.0 | [-0.40, -0.24] | -0.18 | 1pp more mobile → -$0.32 revenue |
| ... | | | | | | |
## Diagnostics
- Residuals vs predicted: <looks random | shows funnel pattern (heteroscedasticity) | shows curvature (non-linearity)>
- Q-Q plot: <residuals roughly normal | heavy tails>
- VIF: <max VIF = 3.1 (OK) | max VIF = 12.4 (multicollinearity warning)>
- Autocorrelation: <Durbin-Watson = 1.94 (OK)>
## Caveats
- <e.g., predictions outside the training range of feature X are extrapolation; not reliable>
- <e.g., model assumes effects are linear; non-linear effects detected for feature Y>
- <e.g., R² inflated by 0.07 vs out-of-time R²; mild overfitting>
## Next steps
- <e.g., target seasonal effects with interaction terms>
- <e.g., investigate residual cluster around segment Z>
- <e.g., if pure prediction matters, benchmark vs gradient boosting>Validation checks
- Target distribution inspected; transformation decision documented
- Outliers checked and policy stated
- No leakage in features
- Residual diagnostics ran (linearity, homoscedasticity, normality)
- VIF checked for multicollinearity
- CIs reported alongside coefficients
- Out-of-time R² compared to in-sample R²
Edge cases & failure modes
- Heavy-tailed target (revenue): OLS gives undue weight to outliers. Use log-transform or quantile regression.
- Zero-inflated target: many zeros + continuous positives (e.g., revenue with many free users). Use two-part model: P(zero) via logistic, then OLS on positive values.
- Multicollinearity: coefficients become unstable. Drop one of correlated pair, or use ridge regression.
- Non-linear relationships: residuals show U-shape vs predicted. Add polynomial terms or use a tree-based model.
- Heteroscedasticity: residuals fan out at higher predicted values. Coefficient SEs are wrong. Use HC3 robust SEs (
cov_type='HC3'in statsmodels). - Time-series autocorrelation: residuals from consecutive periods correlated. SEs are too small. Use Newey-West SEs.
Scripts
scripts/fit_linear.py— End-to-end OLS fit + diagnostics + report.
python scripts/fit_linear.py \
--input data.csv \
--target revenue_per_user \
--features feature_list.txt \
--transform log1p \
--split-by month --split-date 2026-03-01Related skills
data-quality-audit— run before fittinglogistic-regression— binary outcomescausal-inference— when you need effect estimation, not just associationstakeholder-readout— for packaging the model output
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

