python-regression-statistics

Guide regression analysis and outlier detection in Python using statsmodels, scikit-learn, scipy, and PyOD.

34|7|Updated Nov 29, 2025
One-click install
npx skills add https://github.com/jkitchin/skillz --skill python-regression-statistics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-regression-statistics
Source: https://github.com/jkitchin/skillz/tree/main/skills/programming/python-regression-statistics
Command: npx skills add https://github.com/jkitchin/skillz --skill python-regression-statistics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires statsmodels, scikit-learn, scipy, pandas, numpy, pyod, matplotlib, and includes references (resource) components.

What problem does it solve?

This Skill covers regression analysis, diagnostics, and outlier detection in Python using statsmodels, scikit-learn, scipy, and PyOD, with ready-made workflows for inference and validation.

Core Features & Use Cases

  • Statistical regression: OLS, GLM, time-series models with inference.
  • ML regression: Ridge, Lasso, ElasticNet, cross-validation.
  • Outlier detection: Multiple detectors (isolation forest, LOF, COPOD, ECOD) and ensembles.

Quick Start

Request an end-to-end regression workflow: fit an OLS model with confidence intervals, validate assumptions, and produce a diagnostic plot.

Frequently Asked Questions about python-regression-statistics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fit a regression model with statistical inference in Python?

Regression models with p-values and confidence intervals are built using statsmodels for OLS, GLM, and time-series approaches. Fit a model, extract coefficients with confidence intervals, and validate assumptions using diagnostic tests and residual plots.

What's the best way to check regression model assumptions?

Regression diagnostics use residual analysis, VIF for multicollinearity, Cook's distance for influential points, and Q-Q plots for normality. These checks identify assumption violations before interpreting coefficients or making predictions.

How do I detect and handle outliers in regression analysis?

Outlier detection uses PyOD's isolation forest, LOF, COPOD, and ECOD detectors or ensemble methods to flag anomalies. Remove or downweight outliers, then refit the regression model to improve fit and inference quality.

Can I use cross-validation and prediction intervals with regression models?

Cross-validation validates model generalization using scikit-learn's CV tools; statsmodels provides prediction intervals that quantify uncertainty around forecasts. Combine both for robust end-to-end validation pipelines.

When should I use statistical regression versus machine-learning regression?

Statistical regression (OLS, GLM via statsmodels) prioritizes inference, p-values, and interpretability; ML regression (Ridge, Lasso, ElasticNet via scikit-learn) prioritizes prediction accuracy. Choose based on whether you need hypothesis tests or predictive performance.

Does statsmodels support weighted least squares and robust regression?

Yes, statsmodels provides WLS for heteroscedastic data and robust regression methods to reduce outlier influence. Both fit alternative models when standard OLS assumptions are violated.