/engineering:python-ml-predictivefrom engineering
Builds and deploys predictive ML models (scikit-learn, Prophet, statsmodels) for SaaS features: forecasting, classification, regression, anomaly detection, churn/risk scoring. Covers data prep, model serving, monitoring, and explainability.
Ships in engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.
| Category | Artifact | Format | Example |
|---|---|---|---|
| Correctness | Model evaluation report | Markdown doc covering train/test split, baseline comparison, and per-segment metrics | docs/python/ml-eval-2026-04-16.md |
| Operability | Model deployment runbook | Markdown doc per skill-composition-standards/references/runbook-template.md covering deploy, drift detection, and re-train procedure | docs/python/ml-runbook.md |
references/ directory for deep detail after reading the core workflow below.Real statistical / machine-learning models for SaaS features: forecasting, classification, regression, anomaly detection. Complements the LLM-based ai-* skills — use ML/stats when the problem is numeric, data-rich, and requires explainable, stable outputs.
Prerequisites: Load python-modern-standards and python-saas-integration before this skill. Load python-data-analytics for feature engineering.
Skill-specific references:
references/when-ml-vs-llm-vs-rules.mdreferences/data-prep.mdreferences/forecasting-prophet.mdreferences/forecasting-statsmodels.mdreferences/classification-regression-sklearn.mdreferences/anomaly-detection.mdreferences/evaluation-metrics.mdreferences/model-serving.mdreferences/monitoring-and-drift.mdreferences/ml-system-architecture-fti.mdreferences/explainability.mdInput type alone does not select the model. For a text label, compare an explicit rule and a small conventional classifier with any LLM candidate on the same permitted examples. For generated prose or extraction that must generalise across varied instructions, evaluate an LLM against the exact workflow. Keep a human review or abstention path when errors carry material cost.
Choose the simplest option that meets the measured quality, review-capacity, privacy, and operating constraints. Compare false-positive and false-negative costs at the actual action threshold. A classifier can rank cases for a limited review queue; a rule may be enough when its conditions are stable and complete. Change the model only when a held-out comparison shows a useful improvement for the intended workload.
See references/when-ml-vs-llm-vs-rules.md for the worked ticket-triage decision and offline classifier example.
Avoid starting with deep learning. Tabular SaaS problems are almost always best solved with gradient-boosted trees or linear models. Deep learning earns its keep only for unstructured data (text, images, audio) — for which we usually call LLMs or pre-trained models instead of training from scratch.
Leakage is the silent killer. Prevent it with process, not vigilance.
Splits:
train_test_split(..., stratify=y).GroupKFold. Never let the same customer appear in train and test.Leakage sources to eliminate:
Always wrap preprocessing in a Pipeline so fit-on-train/apply-on-test is automatic:
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
from sklearn.ensemble import GradientBoostingClassifier
preprocess = ColumnTransformer([
("num", StandardScaler(), numeric_cols),
("cat", OneHotEncoder(handle_unknown="ignore", min_frequency=10), categorical_cols),
])
model = Pipeline([("prep", preprocess), ("clf", GradientBoostingClassifier(random_state=42))])
model.fit(X_train, y_train) # scaler fits only on train
See references/data-prep.md.
Prophet — use when you have daily or weekly data with yearly / weekly seasonality and holidays matter. Minimal tuning, business-friendly confidence intervals.
from prophet import Prophet
df_fc = df.rename(columns={"date": "ds", "sales": "y"})
m = Prophet(yearly_seasonality=True, weekly_seasonality=True, holidays=kenya_holidays)
m.fit(df_fc)
future = m.make_future_dataframe(periods=90, freq="D")
forecast = m.predict(future) # yhat, yhat_lower, yhat_upper
statsmodels ARIMA / SARIMA / ETS — use when you need rigor (AIC, residual diagnostics, significance), simple series without holidays, or when Prophet is overkill.
from statsmodels.tsa.statespace.sarimax import SARIMAX
model = SARIMAX(y_train, order=(1, 1, 1), seasonal_order=(1, 1, 1, 12))
res = model.fit(disp=False)
forecast = res.get_forecast(steps=12)
mean = forecast.predicted_mean
ci = forecast.conf_int()
Always produce intervals, not just point forecasts. Users need to see uncertainty. See references/forecasting-prophet.md and references/forecasting-statsmodels.md.
Default model order to try:
Hyperparameter tuning: RandomizedSearchCV with a small budget first, then refine. Don't grid-search over 10,000 combinations.
Metrics — never just accuracy:
See references/classification-regression-sklearn.md and references/evaluation-metrics.md.
Three tiers in order of complexity:
from sklearn.ensemble import IsolationForest
iso = IsolationForest(contamination=0.01, random_state=42).fit(X_train)
scores = -iso.score_samples(X_new) # higher = more anomalous
Calibrate thresholds on a known-clean period. Re-calibrate monthly. See references/anomaly-detection.md.
Lightweight by default. No MLflow/Kubeflow unless you're genuinely running dozens of models.
Serialization: joblib.dump(model, path). Pin sklearn/xgboost versions in pyproject.toml — pickle format breaks across major versions.
Loading: eager-load at sidecar startup or worker startup. Keep the model in memory for the life of the process. Never load per request.
# src/service_name/ml/churn.py
from joblib import load
from pathlib import Path
MODEL_PATH = Path(__file__).parent / "artifacts" / "churn_v3.joblib"
_model = load(MODEL_PATH) # loads once at import
def score(features: dict) -> float:
X = build_feature_frame(features)
return float(_model.predict_proba(X)[0, 1])
Versioning: filename includes semver or date (churn_v3.joblib, demand_20260301.joblib). Current version is a symlink. Rollback = flip symlink + restart.
A/B tests / shadow mode: run new model alongside old on same inputs, log both predictions, compare offline.
See references/model-serving.md.
Models degrade silently. Detect it.
Feature drift: distributions of inputs shift over time. Monitor mean, std, quantiles of each input feature vs. a reference window. Use population stability index (PSI) or Kolmogorov-Smirnov statistic.
Prediction drift: distribution of predictions shifts. Cheap proxy for feature drift.
Performance drift: requires labels (arriving later). Log predictions, match to truth when it arrives, compute rolling metric.
Alert when: PSI > 0.2 for any feature, or monthly metric deviates > N% from training baseline.
Retraining triggers: calendar (monthly/quarterly), drift alert, or drop in business KPI.
See references/monitoring-and-drift.md.
Users and regulators ask "why?" Have an answer.
Global: feature importance from the model (model.feature_importances_ for trees, coefficients for linear).
Local (per prediction): SHAP values. Log top-3 contributing features per prediction for high-stakes scores (credit, risk, fraud).
import shap
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_sample)
Confidence intervals on predictions matter as much as the prediction itself. Regressors: use quantile regressors or bootstrap. Classifiers: calibrate probabilities with CalibratedClassifierCV.
See references/explainability.md.
Load references/ml-system-architecture-fti.md when the model must run beyond a notebook: splitting feature, training and inference pipelines, deciding on a feature store, building point-in-time correct training data, coupling model and feature versions, online fallbacks, or placing an LLM/RAG feature in the same architecture.
Sidecar (sync scoring): small, fast models. POST /score → features in → prediction + confidence out. Latency budget < 200ms.
Worker (batch scoring): nightly scoring of all customers for churn; bulk forecast for all SKUs. Writes results to MySQL where PHP reads them.
Training: worker job, runs on a schedule. Output: new model artifact + metrics report. Never train in a sidecar.
class_weight="balanced", or downsample, or use threshold tuning.model.predict(X) inside the request handler without timeout or concurrency limits.ai-predictive-analytics — LLM-based prediction; compare against a conventional classifier for text labels.ai-evaluation — for LLM output quality; ML evaluation is different (this skill).saas-business-metrics — to decide which outcome to model.| Condition | Action |
|---|---|
| Stable explicit rules meet the need | Use rules, not a model |
| Labelled data and measurable target exist | Compare a simple baseline first |
| Leakage, consent, or evaluation data is unresolved | Stop and repair the data contract |
Read access to data definitions is required. Execution is required to claim measured quality; editing and deployment require authorisation.
Fallback: without executable data, return an experiment design and serving contract only. Label metrics as targets or examples.
| Artefact | Required? | Purpose |
|---|---|---|
| Prediction objective, labelled data, baseline, evaluation metric, and deployment constraints | yes | Prevent target and validation errors |
examples/release-diagnostics/diagnose.py (opens in a new tab)examples/release-diagnostics/fixture.json (opens in a new tab)examples/ticket-triage/regression_metrics.py (opens in a new tab)examples/ticket-triage/score.py (opens in a new tab)examples/ticket-triage/test.csv (opens in a new tab)examples/ticket-triage/test_example.py (opens in a new tab)examples/ticket-triage/train.csv (opens in a new tab)examples/ticket-triage/train.py (opens in a new tab)references/anomaly-detection.md (opens in a new tab)references/classification-regression-sklearn.md (opens in a new tab)references/data-prep.md (opens in a new tab)references/evaluation-metrics.md (opens in a new tab)references/explainability.md (opens in a new tab)references/forecasting-prophet.md (opens in a new tab)references/forecasting-statsmodels.md (opens in a new tab)references/ml-system-architecture-fti.md (opens in a new tab)references/model-serving.md (opens in a new tab)references/monitoring-and-drift.md (opens in a new tab)references/when-ml-vs-llm-vs-rules.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub peterbamuhigire/chwezi-dev-engine --plugin engineering169 skills in this plugin
/accounting-engineUse when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements./accounting-finance-controllerUse when coordinating accounting and finance implementation reviews, doctrine routing, control evidence, remediation priorities, and release decisions across a software system./advanced-testing-strategyUse when designing or reviewing test strategy for production systems, APIs, mobile apps, SaaS platforms, ERP workflows, and AI-enabled systems. Covers unit, integration, contract, end-to-end, regression, release-gate, and risk-based testing decisions.Other plugins' skills for the same job