Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

python-regression-statistics

БесплатноЗапускает вложенные скриптыНе проверен

Expert guidance for regression analysis, statistical modeling, and outlier detection in Python using statsmodels, scikit-learn, scipy, and PyOD - includes…

jkitchinот jkitchin★ 45 звёзд на GitHub19 установок в других каталогах

Об этом скилле

Python Regression & Statistical Analysis

Expert assistant for regression analysis, statistical modeling, and outlier detection in Python. This skill covers statsmodels for statistical regression, scikit-learn for machine learning approaches, scipy for statistical methods, and PyOD for comprehensive outlier detection.

When to Use This Skill

  • Fitting linear and nonlinear regression models with proper statistical inference
  • Checking and validating regression assumptions (LINE: Linearity, Independence, Normality, Equal variance)
  • Performing model diagnostics: residual analysis, influential points, multicollinearity
  • Detecting and handling outliers using statistical, proximity-based, and ensemble methods
  • Comparing statistical vs machine learning regression approaches
  • Building robust regression pipelines with proper validation
  • Time series modeling and forecasting
  • Generalized linear models (GLM) for non-normal response variables

Philosophy: Statistical vs Machine Learning Approaches

Statistical Regression (statsmodels, scipy.stats)

Use when:

  • You need p-values, confidence intervals, and hypothesis testing
  • Understanding which variables are significant is important
  • You want to interpret coefficients causally
  • Sample size is moderate and you need inference guarantees
  • You need diagnostic tests for assumptions

Advantages:

  • Rich statistical inference (t-tests, F-tests, likelihood ratios)
  • Comprehensive diagnostics and assumption tests
  • Formula interface for easy model specification
  • Standard errors, confidence intervals, prediction intervals
  • Well-understood theoretical properties

Limitations:

  • Less flexible for complex nonlinear relationships
  • Requires careful assumption checking
  • May not handle high-dimensional data well
  • Less automated feature selection

Machine Learning Regression (scikit-learn)

Use when:

  • Prediction accuracy is the primary goal
  • You have many features and complex interactions
  • Relationships are highly nonlinear
  • You don't need statistical inference (p-values)
  • You have sufficient data for train/test splits

Advantages:

  • Handles complex nonlinear patterns
  • Built-in regularization (Ridge, Lasso, ElasticNet)
  • Excellent for high-dimensional data
  • Automated cross-validation and hyperparameter tuning
  • Ensemble methods for improved accuracy

Limitations:

  • No automatic p-values or statistical inference
  • Less interpretable coefficients
  • Requires more data for complex models
  • Black-box nature for some algorithms

Recommended Workflow

# 1. Exploratory Data Analysis
# - Visualize relationships (scatter plots, pair plots)
# - Check distributions (histograms, Q-Q plots)
# - Identify potential outliers (box plots, scatter plots)
# - Calculate summary statistics

# 2. Initial Outlier Screening (Optional)
# - Use multiple detection methods (IQR, Z-score, isolation forest)
# - Visualize flagged points
# - Investigate why they're outliers (data errors vs real extremes)
# - Document decision to keep or remove

# 3. Check Assumptions (for statistical regression)
# - Linearity: residual vs fitted plots, partial regression plots
# - Independence: Durbin-Watson test, autocorrelation plots
# - Normality: Q-Q plots, Shapiro-Wilk test, histogram of residuals
# - Equal variance: scale-location plot, Breusch-Pagan test

# 4. Model Fitting
# - Start simple (OLS) then add complexity as needed
# - Try transformations if assumptions violated (log, Box-Cox)
# - Consider robust methods if outliers present
# - Use regularization if many predictors (Ridge/Lasso)

# 5. Model Diagnostics
# - Residual analysis
# - Check for influential points (Cook's D, DFFITS, leverage)
# - Multicollinearity (VIF)
# - Outliers in predictor space vs response space

# 6. Validation
# - Train/test split or cross-validation
# - Compare multiple models (AIC, BIC, R², RMSE)
# - Check prediction intervals (statistical) or residual distribution (ML)

# 7. Interpretation & Reporting
# - Coefficient interpretation with confidence intervals
# - Feature importance (if ML model)
# - Visualize predictions vs actuals
# - Report diagnostics and assumption checks

Statistical Regression with statsmodels

Ordinary Least Squares (OLS)

import statsmodels.api as sm
import statsmodels.formula.api as smf
import numpy as np
import pandas as pd

# Arrays API - more control
X = sm.add_constant(X_raw)  # Add intercept
model = sm.OLS(y, X)
results = model.fit()
print(results.summary())

# Formula API - easier specification
df = pd.DataFrame({'y': y, 'x1': x1, 'x2': x2, 'category': cat})
model = smf.ols('y ~ x1 + x2 + C(category)', data=df)
results = model.fit()

# Access key results
results.params           # Coefficients
results.pvalues         # P-values
results.conf_int()      # Confidence intervals
results.rsquared        # R²
results.rsquared_adj    # Adjusted R²
results.aic, results.bic  # Information criteria
results.resid           # Residuals
Полный SKILL.md на GitHub

Установить python-regression-statistics в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

*

Вложенные файлы

QUICK_REFERENCE.mdREADME.mdexamples/ml_comparison.pyexamples/ols_diagnostics.pyexamples/outlier_detection.pyexamples/robust_regression.pyexamples/time_series.pyreferences/diagnostics_checklist.mdreferences/outlier_methods_comparison.md

FAQ

Что делает скилл python-regression-statistics?

Expert guidance for regression analysis, statistical modeling, and outlier detection in Python using statsmodels, scikit-learn, scipy, and PyOD - includes model diagnostics, assumption checking, robust methods, and comprehensive outlier detection strategies

Как установить скилл python-regression-statistics?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл python-regression-statistics запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить python-regression-statistics с