Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Ml Project Lifecycle?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/fabiandistler-ml-project-lifecycle)
---
name: ml-project-lifecycle
category: ai-ml
environments: coding
description: "Guides a classical ML project from framing to deployment and retraining. Use when training a model on your own data; not for building an LLM app."
metadata:
version: "1.0"
---
# ML Project Lifecycle
Use this skill as a gate to pass through, not a menu to skim: framing the problem, choosing the model, and shipping it safely.
## When to use
- Training a model on your own tabular, image, text, or time-series data: scoping the project, picking a model family, handling missing values, or deciding whether it is good enough to ship and when to retrain.
- Classical ML only.
## Part A — Framing: get the problem right before touching a model
### Business-objectives-first
At project framing and model selection, connect the work to an observable business outcome. Answer three questions:
1. Which business problem does this decision address?
2. Which business metric does it move?
3. How will the connection between the two be measured?
Use the agreed objective to guide feature engineering and evaluation; revisit scope if a change has no plausible path to the business metric.
Ask early whether a plain rule or a prompted LLM could meet the business objective. If a plain rule suffices, use it as the solution. For prompting, RAG, agents, or evals over a foundation model, read `members/llm-application-engineering/SKILL.md` via the `ai-ml` router.
### The baseline gate
Climb this ladder before calling anything deployment-worthy:
| # | Baseline | What it is |
|---|----------|------------|
| 1 | Dummy | Always predict the most frequent class — the floor |
| 2 | Simple heuristic | A hand-written domain rule (e.g. "spam if >5 links") |
| 3 | Linear | Logistic or linear regression on the same features |
| 4 | Strong simple model | Untuned GBDT or tabular foundation model |
| 5 | Zero-shot LLM | Optional comparator for text and label tasks |
| 6 | Incumbent | The current production system, if one exists, with human expert performance as the reference ceiling |
Beat means the candidate's cost-weighted metric clears the baseline's cross-validation spread or bootstrap confidence interval — a point win inside the noise does not count.
### Missing values: prediction default first, mechanism only for inference
For prediction, do not diagnose the missingness mechanism first — MAR and MNAR cannot be distinguished from observed data alone. The default, whatever the mechanism:
- Prefer a model with native NaN handling (`HistGradientBoostingClassifier`/`Regressor`, XGBoost, LightGBM, CatBoost) where the stack allows it; or
- Simple imputation plus a missingness indicator, fit inside CV (see the ordering constraint in Part C): `SimpleImputer(add_indicator=True)` in sklearn, or `step_indicate_na()` plus a `step_impute_*()` step in tidymodels recipes.
Do not default to "drop the row" as a house style — dropping discards the exact signal that makes the missingness informative. Never use the target/outcome when imputing predictors for a prediction task — it leaks the label into the features.
Keep the MCAR/MAR/MNAR taxonomy only for inference and effect estimation, where unbiased estimates (not predictive accuracy) are the goal — there use multiple imputation (MICE) and pool the estimates across imputations.
## Part B — Model selection
### Default model choice
Pick the model family from the shape of the data first, and prefer the boring, well-understood option unless the data specifically calls for more:
| Data type | Default | Notes |
|-----------|---------|-------|
| Tabular, up to about 10k-50k rows | Tabular foundation model (TabPFN, TabICL) alongside untuned CatBoost or LightGBM; check licence before commercial use | Foundation models lead on small and medium data; GBDT stays the untuned comparator |
| Tabular, larger data | XGBoost / LightGBM / CatBoost | GBDT first; tabular deep learning only via RealMLP or TabM |
| Images | Pretrained vision foundation model with transfer learning | Train a CNN backbone only when the foundation model cannot run |
| Text | Zero-shot LLM, then embeddings plus linear model, then fine-tune | Sentence-transformer embeddings are often sufficient without a full fine-tune |
| Time series | AutoETS or Theta plus a zero-shot time-series foundation model (Chronos, TimesFM) | Via statsforecast or fable; Prophet is not a first choice |
Treat specific library and model names as examples of their categories, not permanent recommendations.
### AutoML notes
AutoML (AutoGluon, H2O AutoML, FLAML, or workflowsets in R) gives you an optional comparator for the table's default model family and bundles hyperparameter tuning.
- **Use it for:** a quick baseline, proof-of-concept work, standard well-trodden problems where time matters more than a marginal accuracy gain.
- **Its costs:** it is a black box that is hard to debug, it can overfit to the validation data, it gets expensive on large datasets, and it cannot encode domain-specific structure a practitioner knows about.
Move to deep learning only when the baseline misses a genuine business need.
## Part C — Pipeline and deployment checklist
### Tooling
| Step | Python | R |
|------|--------|---|
| Pipeline | sklearn Pipeline | tidymodels workflow with recipes |
| Versioning and deployment | vetiver plus pins, MLflow 3 LoggedModel plus registry | vetiver plus pins |
| Monitoring | vetiver monitoring, MLflow | vetiver monitoring |
### Preprocessing and feature engineering
Choose transformations that fit the data and model: missing-value handling as
above, scaling, categorical encoding, feature crossing, or sequence embeddings.
<a id="fit-preprocessing-inside-cv"></a>
Fit every learned step (imputation, scaling, encoding, selection and tuning) only on training folds inside CV. Fitting any statistic before splitting leaks test information into training and inflates validation performance.
Leakage checklist — pass all six before trusting a validation score:
1. Temporal split — no future information in training; use a time-based split for time-ordered data.
2. Group split — no shared entity across folds (same user, patient, device); split by group.
3. Target-proxy audit — no feature computed from the outcome or only available after it.
4. Duplicate check — no duplicate or near-duplicate rows straddling train and validation.
5. [Preprocessing inside CV](#fit-preprocessing-inside-cv).
6. Test set touched once — the held-out test set is evaluated a single time, never used for tuning.
```python
from sklearn.compose import ColumnTransformer
from sklearn.impute import SimpleImputer
from sklearn.model_selection import GroupKFold, TimeSeriesSplit, cross_val_score
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler
preprocess = ColumnTransformer(
[
(
"num",
Pipeline(
[
("impute", SimpleImputer(strategy="median", add_indicator=True)),
("scale", StandardScaler()),
]
),
numeric_features,
),
(
"cat",
Pipeline(
[
("impute", SimpleImputer(strategy="most_frequent")),
("encode", OneHotEncoder(handle_unknown="ignore")),
]
),
categorical_features,
),
]
)
pipe = Pipeline([("preprocess", preprocess), ("model", model)])
# For grouped observations:
cv = GroupKFold(n_splits=5)
cv_groups = groups
# For time-ordered data instead, use these values:
# cv = TimeSeriesSplit(n_splits=5)
# cv_groups = None
scores = cross_val_score(pipe, X, y, cv=cv, groups=cv_groups)
```
```r
library(tidymodels)
rec <- recipe(label ~ ., data = train) %>%
step_indicate_na(all_predictors()) %>%
step_impute_median(all_numeric_predictors()) %>%
step_impute_mode(all_nominal_predictors()) %>%
step_dummy(all_nominal_predictors())
wf <- workflow() %>% add_recipe(rec) %>% add_model(spec)
group_vfold_cv(train, group = entity_id, v = 5)
sliding_period(train, index = timestamp, period = "month", lookback = 12, assess_stop = 1)
```
**Categorical features:** for high-cardinality categories, default to CatBoost's native categorical handling. For another estimator, fit a target encoder within each training fold. Cross-fit training rows by learning their encodings from other rows in that fold, respecting group and time boundaries. Use hashing when the category vocabulary is too large to keep in memory or when you cannot cross-fit without leakage.
For lower cardinality with estimators that need encoded inputs, use unknown-safe one-hot encoding: sklearn `OneHotEncoder(handle_unknown="ignore")`, or recipes `step_novel()` plus `step_other()`.
### Staged deployment
Two tracks — pick the one matching how the model serves.
Online: shadow, then canary with pre-declared rollback metrics, then full rollout. Shadow runs the new model in parallel with predictions logged and zero user impact. Canary graduates traffic in steps with rollback criteria declared before rollout — roll back when a canary metric breaches its bound. Run an A/B test only when the business effect needs causal proof, with sticky assignment.
Batch: backtest on historical windows, then parallel run alongside the incumbent, then switch. Switch only after the parallel run matches the backtest within the pre-declared tolerance.
### Retraining triggers
Retrain on any of these signals, not on a schedule alone:
- **Scheduled** — daily or weekly, as a baseline cadence.
- **Performance degradation** — the business metric from Part A moves beyond the cost bound agreed there, not a fixed percentage.
- **Data-distribution shift** — PSI above 0.25 signals major shift, above 0.1 minor shift; investigate major shifts and monitor minor ones. Use a proxy metric such as prediction distribution or feature means when labels arrive late.
- **Business event** — a product launch, a seasonal change, or another event known to shift the underlying data-generating process.
## Source
This skill distills Chip Huyen, *Designing Machine Learning Systems* (2022); the tabular defaults reflect tabular-foundation-model practice (2024–2026).