
Predictive Analytics
- 19 installs
- 7 repo stars
- Updated May 20, 2026
- daemon-blockint-tech/agentic-enteprises-skill
Guides applied predictive analytics: target/leakage framing, tabular feature engineering, regression and classification models, validation, calibration, and drift monitoring.
About
Guides applied predictive analytics for business covering target framing, leakage audits, feature engineering, model selection, validation, calibration, explainability, and drift monitoring. A developer uses it for churn, demand, fraud, propensity, or risk-score models on tabular data.
- Covers baselines, tree ensembles, gradient boosting, and time-based validation
- Includes calibration, cost-sensitive thresholds, and SHAP-style explainability
Predictive Analytics by the numbers
- 19 all-time installs (skills.sh)
- Ranked #1,273 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
- Data as of Jul 27, 2026 (Skillselion catalog sync)
npx skills add https://github.com/daemon-blockint-tech/agentic-enteprises-skill --skill predictive-analyticsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 19 |
|---|---|
| repo stars | ★ 7 |
| Last updated | May 20, 2026 |
| Repository | daemon-blockint-tech/agentic-enteprises-skill ↗ |
What it does
Guides applied predictive analytics: target/leakage framing, tabular feature engineering, regression and classification models, validation, calibration, and drift monitoring.
Files
Predictive Analytics
When to Use
- Define the prediction target, unit of analysis, horizon, and success criteria before modeling
- Audit leakage, label timing, and train/validation design for tabular or time-ordered data
- Engineer and select features for churn, propensity, fraud, demand, or risk scoring use cases
- Choose model families and baselines (linear, tree ensembles, gradient boosting) matched to data size and interpretability needs
- Run validation: holdout, cross-validation, or time-based splits with metrics aligned to the decision
- Tune calibration, thresholds, and cost-sensitive operating points for classification and scores
- Explain models at practitioner level (importance, partial dependence, SHAP-style intuition—not full XAI research)
- Plan conceptual post-deployment monitoring: drift signals, retrain triggers, and limitation language for stakeholders
When NOT to Use
- MLOps platform build—feature stores, model registry, K8s serving, CI for training pipelines →
ml-infrastructure-engineer-safeguards,ml-ops-engineer(if installed) - Deep learning research, LLM fine-tuning, or novel architecture search →
ml-research-engineer-safeguards,ai-engineer - Actuarial reserving, loss development, rate indication, or regulatory pricing math →
actuarial-analyst,advanced-short-term-actuarial-mathematics,actuary - Dashboard-only KPI layout, chart design, or viz specs without modeling →
data-visualization,bi-analyst - Warehouse/dbt dimensional modeling, mart SQL, or pipeline idempotency only →
data-warehouse-engineer,analytics-data-engineer - A/B test design, power, randomization, and experiment readouts →
ab-testing-engineer - Markets/finance factor research, backtests, and alpha hygiene →
quantitative-researcher - Cloud cost forecasting and FinOps allocation →
finops-analyst
Related skills
| Need | Skill |
|---|---|
| Broader ML lifecycle, causal inference, heavy MLOps detail | data-scientist |
| Factor research, backtests, market time series | quantitative-researcher |
| dbt marts, metric layers, analytics pipelines | analytics-data-engineer |
| Warehouse modeling, ELT, data quality frameworks | data-warehouse-engineer |
| Chart type, dashboard layout, honest viz | data-visualization |
| Experiment design, power, SRM, readouts | ab-testing-engineer |
| Cloud spend models and allocation | finops-analyst |
| Insurance reserving, pricing, regulatory actuarial work | actuarial-analyst |
| GenAI products, agents, LLM application patterns | ai-engineer |
| Training/serving infrastructure and platform guardrails | ml-infrastructure-engineer-safeguards |
Core Workflows
1. Frame the problem and label
1. State the business decision the score or forecast will drive 2. Define target (binary, multiclass, continuous), horizon, and grain (user, account, SKU, region) 3. Document label window and feature cutoff (what is knowable at scoring time) 4. Check base rate, class imbalance, and whether rules/heuristics already suffice 5. List constraints: latency, interpretability, fairness review, regulatory context
See `references/problem_framing_and_data_prep.md`.
2. Prepare data and features
1. Profile missingness, cardinality, outliers, and temporal coverage 2. Build point-in-time feature tables; never join future outcomes into training rows 3. Encode categoricals, scale numerics, and handle high-cardinality keys deliberately 4. Document feature definitions, refresh cadence, and upstream dependencies 5. Split data with the right strategy (random, grouped, or time-based)
See `references/problem_framing_and_data_prep.md`.
3. Model, validate, and compare
1. Fit baselines first (majority class, linear/logistic, naive forecast) 2. Iterate tree ensembles or regularized models; avoid unnecessary complexity 3. Select metrics tied to the decision (PR-AUC for rare events, MAPE vs WAPE for demand, etc.) 4. Use cross-validation or rolling-origin evaluation for time-ordered problems 5. Compare models on holdout data never used for tuning
See `references/modeling_and_validation.md`.
4. Classification, propensity, and scores
1. Calibrate probabilities when ranks are not enough for thresholds or expected value 2. Set thresholds using cost matrices, capacity, or top-decile lift—not default 0.5 3. Report lift, capture, and stability by segment and time 4. Separate model quality from policy (who gets contacted, approved, or reviewed)
See `references/classification_and_propensity.md`.
5. Forecasting and time series (when applicable)
1. Choose granularity (daily/weekly) and horizon aligned to planning cycles 2. Use naive and seasonal baselines; add exogenous features only when available at forecast time 3. Validate with rolling or blocked time splits; report interval or quantile forecasts when decisions need range 4. Document seasonality, promotions, and structural breaks that limit extrapolation
See `references/forecasting_and_time_series.md`.
6. Deploy, monitor, and communicate
1. Specify scoring cadence, input schema, and fallback when features are missing 2. Define monitoring: label delay, score distribution drift, feature drift, and business outcome tracking 3. Set retrain triggers (calendar, performance decay, population shift)—conceptual triggers only here 4. Deliver a model card or memo: intended use, limitations, metrics, and what would falsify trust
See `references/deployment_monitoring_and_communication.md`.
When to load references
| Topic | Reference |
|---|---|
| Role boundaries and deliverables | references/predictive_analytics_scope.md |
| Target, leakage, unit of analysis, data prep | references/problem_framing_and_data_prep.md |
| Model families, splits, metrics, validation | references/modeling_and_validation.md |
| Propensity, calibration, thresholds, costs | references/classification_and_propensity.md |
| Demand forecast and time-series workflow | references/forecasting_and_time_series.md |
| Monitoring, retrain, stakeholder comms | references/deployment_monitoring_and_communication.md |
Classification and Propensity
Table of contents
1. Propensity vs classification 2. Scores, ranks, and probabilities 3. Calibration 4. Threshold selection 5. Cost-sensitive decisions 6. Capacity and workflow constraints 7. Segmentation and stability 8. Common use-case patterns
Propensity vs classification
| Term | Meaning |
|---|---|
| Propensity model | Estimates likelihood of an action (buy, upgrade, churn) |
| Classification model | Assigns a discrete class; may use propensity + threshold |
Propensity models often feed ranking (who to contact first). Classification adds an operating point (approve/deny, flag/review).
Scores, ranks, and probabilities
- Raw score (logit, margin): Good for ranking if monotonic; not calibrated.
- Probability: Needed for expected value, budgeting, and some compliance reviews.
- Decile lift: Compares top decile event rate to population rate—easy for stakeholders.
Report which output production will consume.
Calibration
Uncalibrated models can rank well but misstate risk.
| Method | When |
|---|---|
| Platt scaling | Smaller data; logistic on validation scores |
| Isotonic regression | Larger validation sets; flexible but can overfit small val |
| Beta calibration | Alternative for skewed scores |
Evaluate with reliability diagrams and Brier score on a calibration holdout—not the same fold used for threshold tuning if possible.
Threshold selection
Do not default to 0.5. Choose thresholds by:
1. Cost matrix (FP vs FN costs in business units) 2. Capacity (max reviews, calls, or approvals per day) 3. Target precision (fraud: “at 95% precision, what recall?”) 4. Top-k policy (contact best 5% of list)
Document the expected confusion matrix at the chosen point and sensitivity to ±0.05 score shift.
Cost-sensitive decisions
Example framing:
Expected value = P(positive) * benefit_true_positive
- P(false positive) * cost_false_positive
- action_costWhen costs are unknown, present threshold curves: precision/recall, lift, and workload vs cutoff.
For fraud and compliance queues, pair with anti-false-positive-decision-making when alert volume and evidence bars matter.
Capacity and workflow constraints
| Constraint | Modeling implication |
|---|---|
| Fixed review team | Optimize precision@k or top-N daily |
| SLA on latency | Prefer simpler models; limit feature fan-out |
| Tiered treatment | Multiple thresholds (auto-approve / manual / deny) |
| Human-in-the-loop | Model ranks; policy applies overrides |
Separate model evaluation from operating policy in documentation.
Segmentation and stability
Report metrics by:
- Acquisition cohort, tenure band, product, geography
- Time (train period vs recent holdout month)
- Score decile stability (do top deciles stay top?)
Investigate simpson’s paradox slices where global metrics hide failure modes.
Common use-case patterns
| Use case | Target tips | Metric emphasis |
|---|---|---|
| Churn | Define inactive; handle win-back | PR-AUC, recall@k for save offers |
| Upsell / cross-sell | Eligibility filters on negatives | Lift@k, incremental lift vs control if available |
| Lead scoring | Deduplicate leads; time-decay features | Precision@k for SDR capacity |
| Fraud | Delayed labels; extreme imbalance | Precision at operational review rate |
| Risk tiering (non-actuarial) | Document fair lending / ECOA review path | Ranking + calibration + adverse action inputs (process, not legal advice) |
For experiment-based validation of treatments, route to ab-testing-engineer—do not confuse model lift with campaign lift.
Deployment, Monitoring, and Communication
Table of contents
1. Deployment modes (conceptual) 2. Scoring contract 3. Monitoring signals 4. Drift types 5. Retrain triggers 6. Explainability for stakeholders 7. Model card outline 8. Uncertainty and limitations language 9. Governance handoffs
Deployment modes (conceptual)
| Mode | When | Trade-offs |
|---|---|---|
| Batch scoring | Nightly/weekly lists; churn campaigns | Stale between runs; simple ops |
| Near-real-time | Fraud, routing within minutes | Feature pipeline latency critical |
| On-demand API | Interactive eligibility | Needs SLAs, fallbacks, versioning |
Platform implementation (containers, feature store, autoscaling) → ml-infrastructure-engineer-safeguards. This skill stops at requirements and acceptance criteria.
Scoring contract
Document for engineering partners:
- Input schema: feature names, types, max null rates
- Output: score, probability, decile, optional reason codes
- Version: model ID, training data snapshot date
- Fallback: default score or rules when features missing
- Latency budget and throughput
- Idempotency for batch replays
Monitoring signals
Track at minimum:
| Signal | Question answered |
|---|---|
| Score distribution | Did the model’s output shape shift? |
| Feature distributions | Did inputs change (new product, pricing)? |
| Volume & null rates | Pipeline breaks? |
| Label delay & outcome rate | Is realized churn/fraud rate drifting? |
| Business KPI | Did campaign ROI or loss rate change post deploy? |
| Latency & error rate | Serving health |
Set review cadence (daily for fraud, weekly for churn, etc.).
Drift types
| Type | Symptom | Response (conceptual) |
|---|---|---|
| Data drift | Feature means/quantiles shift | Investigate upstream; retrain or recalibrate |
| Concept drift | Same features, weaker label relationship | Retrain; revisit features |
| Prior shift | Base rate changes | Recalibrate thresholds; adjust capacity |
| Schema drift | Missing columns, type changes | Block scoring; alert owners |
Population Stability Index (PSI) is a common heuristic—document thresholds and false alarm tolerance.
Retrain triggers
Define triggers in advance:
- Calendar (quarterly retrain) for stable domains
- Performance decay (PR-AUC drop vs benchmark on recent labeled window)
- Drift breach (PSI or KS on key features/scores)
- Material business change (new product line, pricing overhaul)
- Regulatory / policy change requiring review
Include rollback plan: keep prior model version until new model passes shadow or champion/challenger checks (conceptual).
Explainability for stakeholders
Practitioner toolkit (not full XAI research):
| Tool | Audience value |
|---|---|
| Global feature importance | What drives the model overall |
| Partial dependence / ICE | Direction of effect for top features |
| SHAP (summary, beeswarm) | Local explanations for cases; watch correlated features |
| Reason codes (top 3–5) | Ops teams for fraud/support |
Caveats to state:
- Importance ≠ causation
- Correlated features split importance arbitrarily
- Explanations trained on historical bias reflect historical decisions
Fairness and adverse action processes are organizational—flag review with legal/compliance; do not provide legal conclusions.
Model card outline
1. Intended use and non-goals 2. Training data (dates, population, exclusions) 3. Target definition and horizon 4. Features (categories, PII, refresh) 5. Metrics on holdout and key slices 6. Calibration and threshold policy 7. Limitations and known failure segments 8. Monitoring plan and owners 9. Version history and approval sign-off
Uncertainty and limitations language
Prefer:
- “On holdout data from Q1–Q3, top decile had 3.2× lift vs random.”
- “Precision at our review capacity (2k/day) was 42%; expect ±5% if base rate shifts.”
- “Forecasts are median scenarios; intervals covered 80% of holdout weeks.”
Avoid:
- “The model proves causation.”
- “Accuracy is 99%” without prevalence context.
- Point forecasts without horizon or segment caveats.
Governance handoffs
| Topic | Skill |
|---|---|
| Experiment validation of interventions | ab-testing-engineer |
| BI reporting of scores | bi-analyst, data-visualization |
| Feature pipeline ownership | analytics-data-engineer |
| Model platform & serving | ml-infrastructure-engineer-safeguards |
| AI system risk tiering | ai-risk-governance |
| Alert disposition policy | anti-false-positive-decision-making |
Forecasting and Time Series
Table of contents
1. When this applies 2. Problem setup 3. Baselines 4. Feature patterns 5. Model choices (tabular focus) 6. Validation for time order 7. Intervals and scenarios 8. Demand forecasting pitfalls 9. Handoff to stakeholders
When this applies
Use this reference when the target is future values over time (demand, volume, revenue, tickets) rather than a one-time entity label. For cross-sectional tabular classification, use classification_and_propensity.md.
Markets-style factor research and backtests → quantitative-researcher.
Problem setup
Define explicitly:
| Choice | Example decisions |
|---|---|
| Granularity | Daily vs weekly vs monthly |
| Horizon | h=1 step vs multi-step (1–13 weeks) |
| Geography / SKU scope | Hierarchy for reconciliation |
| Target | Units, revenue, orders; handle returns and cancellations |
| Exogenous inputs | Promotions, price, holidays—available at forecast origin |
Align granularity with planning cadence (ops buys weekly; finance plans monthly).
Baselines
Required before ML:
| Baseline | Description |
|---|---|
| Naive | Last observed value |
| Seasonal naive | Same period last year/week |
| Moving average | Simple smooth; transparent |
| Linear trend | Quick sanity on drift |
Report MASE (vs seasonal naive) when seasonality is strong—scale-free comparison.
Feature patterns
Lag and window features (all computed with cutoff at origin time):
- Lags:
y_{t-1},y_{t-7},y_{t-52} - Rolling means / std / min / max over windows
- Calendar: day-of-week, month, holiday flags
- Promotions: lead/lag flags only if known in advance
- Price and stock: use planned price; document stockout censoring
Avoid global normalization that uses future series statistics.
Model choices (tabular focus)
| Approach | Fit |
|---|---|
| Regularized linear on lags | Strong baseline; interpretable coefficients |
| Gradient boosting on lag features | Common production choice for heterogeneous series |
| Global model across series | Shared model with series ID feature; needs enough history per series |
| Classical ARIMA/ETS (workflow level) | Univariate benchmarks; seasonality explicit |
| Prophet-style decomp (if used) | Document holidays and changepoints; validate on rolling origin |
Deep sequence models are out of default scope unless paired with data-scientist / research skills.
Validation for time order
Never shuffle time randomly for final evaluation.
| Method | Purpose |
|---|---|
| Holdout tail | Last N periods as test |
| Rolling-origin CV | Retrain on expanding window; score next h steps |
| Blocked CV | Multiple contiguous test blocks for regime coverage |
Report error by horizon step (h=1 often easier than h=4).
Intervals and scenarios
Stakeholders often need ranges, not only point forecasts:
- Quantile regression or conformal-style intervals (workflow level)
- Scenario overlays: promo on/off, supply shock assumptions
- Clearly label intervals are not guarantees—coverage on holdout only
Demand forecasting pitfalls
| Pitfall | Mitigation |
|---|---|
| Stockouts suppress demand | Model censored demand or flag stockout periods |
| Promotions in future unknown | Separate promo-driven vs base forecast |
| New SKU cold start | Hierarchical pooling; analog series |
| One-off spikes (COVID) | Exclude or tag regime; document |
| Reconciliation mismatch | Top-down vs bottom-up reconciliation rules with finance |
Handoff to stakeholders
Deliver:
1. Forecast table with horizon, grain, point, optional intervals 2. Accuracy history on holdout by horizon and key segments 3. Assumptions (promo calendar, price list, capacity) 4. Known failure modes (new markets, sparse history)
Visualization of forecasts → data-visualization; warehouse pipelines for history → analytics-data-engineer.
Modeling and Validation
Table of contents
1. Modeling philosophy 2. Baseline ladder 3. Model families 4. Feature selection 5. Hyperparameters and tuning 6. Validation design 7. Metrics by problem type 8. Diagnostics and sanity checks
Modeling philosophy
- Simple first: If baselines are strong, complexity needs a measured lift.
- Match interpretability to stakeholder needs and regulatory review.
- Separate offline model selection from policy (thresholds, queues, budgets).
- Document random seeds, data snapshots, and library versions for reproducibility.
Baseline ladder
Always report at least one baseline before advanced models:
| Problem | Baselines |
|---|---|
| Binary classification | Majority class; prevalence; simple rules (e.g., tenure > X) |
| Multiclass | Stratified majority; one-vs-rest logistic on few features |
| Regression | Mean/median; last value (for series); seasonal naive |
| Ranking / propensity | Random score; single-feature sort (recency, spend) |
If uplift over baseline is small, question whether ML is worth operational cost.
Model families
| Family | When to use | Caveats |
|---|---|---|
| Regularized linear / logistic | Linear-ish effects, high interpretability, wide sparse data | Needs careful encoding; interactions manual |
| Tree ensembles (RF, GBDT) | Tabular default for medium/large data | Watch overfit on small data; document monotonic constraints if used |
| Gradient boosting (XGBoost, LightGBM, CatBoost) | Strong tabular performance | Tune carefully; handle categoricals per library |
| GLM / GAM (optional) | Smooth terms, insurance-style transparency | Not a substitute for actuarial sign-off |
Avoid deep learning for typical business tabular problems unless data-scientist or research skills justify it.
Feature selection
Principles:
1. Domain-first: Keep features with causal or operational story when possible. 2. Remove redundant highly correlated columns after documenting which to keep. 3. Use embedded selection (L1, tree importance) on training folds only—not holdout. 4. Prefer stability across CV folds over single-run importance rankings. 5. Cap dimensionality when rows are limited (rules of thumb: tens of features per thousand positives for rare events).
Do not iterate feature sets using holdout performance.
Hyperparameters and tuning
- Tune on inner CV or a dedicated validation fold.
- Track search budget; avoid exhaustive grids on large data without need.
- Record best params and variance across folds—a lucky fold is not production-ready.
- For boosting: watch early stopping on validation; document
n_estimatorseffective count.
Validation design
| Method | Use when |
|---|---|
| Single holdout | Large IID data; final gate only |
| k-fold CV | Medium data; hyperparameter selection |
| Group k-fold | Repeated measures per customer/account |
| Rolling-origin | Time-ordered rows; forecasts and drift-prone populations |
| Nested CV | Unbiased estimate when heavy tuning (report outer fold metrics) |
Final holdout is touched once for the delivery report unless deploying iterative research under governance.
Metrics by problem type
Binary classification (imbalanced)
| Metric | Role |
|---|---|
| PR-AUC | Primary for rare positives |
| ROC-AUC | Supplementary; can look optimistic when negatives dominate |
| Precision@k / lift@k | Aligns to top-decile campaigns |
| Brier score | Calibration quality |
| Confusion at operating point | Tie to capacity and costs |
Avoid accuracy as the sole metric when prevalence < 10%.
Multiclass
Macro vs weighted F1 depending on whether rare classes matter equally; report per-class recall for operational classes.
Regression
| Metric | Notes |
|---|---|
| MAE | Robust, same units as target |
| RMSE | Penalizes large errors |
| MAPE / WAPE | Scale-free; beware zeros (use WAPE or sMAPE) |
| Quantile loss | When reporting P10/P50/P90 forecasts |
Forecasting
Report accuracy by horizon bucket (1-step vs 4-step ahead). See forecasting_and_time_series.md.
Diagnostics and sanity checks
- Calibration plot (reliability curve) for classifiers used with thresholds
- Residual plots for regression; heteroscedasticity and tail errors
- Learning curves (train vs val) for over/underfit
- Slice analysis: time cohorts, regions, product lines, acquisition channel
- Score stability: rank correlation month-over-month on holdout cohorts
Flag any slice where the model is worse than baseline before release.
Predictive Analytics — Scope
Table of contents
1. Role definition 2. In scope 3. Out of scope 4. Typical use cases 5. Deliverables 6. Quality bar
Role definition
Predictive Analytics covers applied supervised learning for business decisions: defining what to predict, building tabular features, training and validating models, and communicating scores or forecasts with explicit uncertainty and limitations. The focus is practitioner-grade workflow—not research novelty, not platform engineering, and not actuarial statutory methods.
In scope
| Area | Examples |
|---|---|
| Problem framing | Target, horizon, grain, label timing, leakage checks |
| Data prep | Point-in-time joins, train/val/test design, imbalance handling |
| Feature engineering | Encodings, aggregations, lags, RFM-style behavior features |
| Model families | Linear/logistic, regularized GLMs, tree ensembles, gradient boosting |
| Validation | Holdout, k-fold, grouped CV, rolling-origin for time series |
| Metrics | Classification, ranking, regression, forecast accuracy by horizon |
| Calibration & thresholds | Platt/isotonic concepts, cost-sensitive cutoffs, capacity constraints |
| Explainability (practitioner) | Global importance, partial dependence, SHAP intuition |
| Deployment concepts | Batch vs real-time scoring, drift monitors, retrain triggers |
| Communication | Model cards, limitation language, segment stability |
Out of scope
| Area | Route to |
|---|---|
| Feature stores, model registry, K8s serving, training CI | ml-infrastructure-engineer-safeguards, ml-ops-engineer |
| Deep learning, LLM training, embedding research | ml-research-engineer-safeguards, ai-engineer |
| Reserving, ratemaking, capital, regulatory actuarial | actuarial-analyst, advanced-short-term-actuarial-mathematics |
| Chart/dashboard design without modeling | data-visualization, bi-analyst |
| dbt, warehouse modeling, pipeline orchestration | analytics-data-engineer, data-warehouse-engineer |
| A/B tests, power, randomization | ab-testing-engineer |
| Factor/backtest research for markets | quantitative-researcher |
Typical use cases
| Use case | Target type | Common pitfalls |
|---|---|---|
| Churn / retention | Binary or time-to-event proxy | Label leakage from post-cancel activity |
| Propensity / upsell | Binary or multiclass | Treating all contacts as independent when accounts cluster |
| Demand forecast | Continuous count or revenue | Using future promotions as features |
| Fraud / abuse score | Binary, heavy imbalance | Evaluating only accuracy; ignoring investigation capacity |
| Credit-style risk (non-actuarial) | Binary or score | Fairness and policy separation from model rank |
| Lead scoring | Binary | Stale CRM features; duplicate leads across campaigns |
Deliverables
1. Problem brief — decision, target, horizon, grain, exclusions 2. Data dictionary — features, cutoff rules, refresh cadence 3. Validation report — splits, metrics, baselines, segment slices 4. Model artifact spec — inputs, outputs, versioning, fallback behavior 5. Threshold / policy memo — costs, capacity, expected confusion matrix at operating point 6. Model card — intended use, limitations, monitoring plan, owner
Quality bar
Work is ready to hand off when:
- [ ] Baseline beats are documented; complexity is justified
- [ ] Leakage and label timing are explicitly ruled out or flagged
- [ ] Holdout or rolling evaluation was not used for hyperparameter tuning
- [ ] Metrics match the business decision (not accuracy alone on rare events)
- [ ] Segments (time, region, product) show stability or known gaps
- [ ] Limitations and retrain triggers are stated in plain language
Problem Framing and Data Prep
Table of contents
1. Decision-first framing 2. Target and horizon 3. Unit of analysis and grain 4. Leakage checklist 5. Label construction 6. Feature cutoff rules 7. Data quality gates 8. Split strategies
Decision-first framing
Start from the action, not the algorithm:
- Who receives the prediction, and what do they do differently?
- What is the cost of false positives vs false negatives (or forecast error direction)?
- Is a score rank enough, or are calibrated probabilities / dollar forecasts required?
- Can a simple rule or segmentation deliver 80% of value?
Document answers before selecting features or models.
Target and horizon
| Element | Questions to answer |
|---|---|
| Target | What exact field or derived label? Binary, multiclass, continuous? |
| Horizon | Predict 30-day churn vs 90-day; next-week demand vs next-quarter |
| Observation window | How much history is required before a row is scorable? |
| Delay | How long until labels are observable (fraud chargebacks, churn confirmation)? |
Align horizon with when the business can act and when features are frozen.
Unit of analysis and grain
Pick one primary grain and stick to it:
- User — consumer apps, subscriptions
- Account / customer — B2B, householding rules documented
- SKU-location-day — retail demand
- Transaction — fraud (often with user/account aggregates as features)
If labels exist at a different grain (e.g., account churn from user events), define aggregation rules explicitly and avoid duplicate rows that inflate confidence.
Leakage checklist
Leakage makes offline metrics lie. Audit for:
- [ ] Features computed after the prediction moment (including “current status” fields)
- [ ] Target information embedded in features (e.g.,
cancellation_reasonbefore cancel) - [ ] Random train/test split on time-series or repeated measures per entity
- [ ] Future aggregates (30-day spend including days after scoring date)
- [ ] Test set used for feature selection, imputation stats, or target encoding fit globally
- [ ] Duplicate entities across train and test without grouped splits
- [ ] Survivorship (only customers who stayed long enough to get a label)
When in doubt, rebuild features with a strict as-of timestamp per row.
Label construction
| Pattern | Guidance |
|---|---|
| Binary churn | Define active vs churned with inactivity threshold; handle reactivations |
| Propensity | Label positive only if action occurred within window; negative = eligible but no action |
| Fraud | Use confirmed fraud labels; document delay and partial labels |
| Demand | Align to fulfillment calendar; handle stockouts and censored demand |
Document class balance and whether negatives are “true negatives” or “not yet positive.”
Feature cutoff rules
For each feature, record:
1. Source table and refresh lag 2. As-of rule (e.g., events with event_time < score_time) 3. Aggregation window (7d, 30d, lifetime-with-decay) 4. Default when missing (and whether missingness is informative)
Prefer interpretable aggregates over opaque embeddings unless ml-research-engineer-safeguards scope applies.
Data quality gates
Before modeling:
- Coverage by time, segment, and key dimensions
- Cardinality and rare level handling plan
- Outlier policy (cap, winsorize, flag)—document, do not silently drop
- Consistency between training snapshot and production schema
- Join fan-out checks (one-to-many explosions)
Split strategies
| Data regime | Split approach |
|---|---|
| IID tabular | Stratified random holdout; k-fold CV for tuning |
| Many rows per entity | Group CV by entity ID |
| Time-ordered | Time-based holdout; rolling-origin CV |
| Deployment geography | Hold out regions or cohorts for robustness |
Never tune on the final holdout. For time series, see forecasting_and_time_series.md.