Skip to main content

ML Project Lifecycle

Docs: Google: Rules of ML Β· Google: Problem framing Β· scikit-learn user guide

Overview​

The model is the easy part. Training is one afternoon out of weeks of work; the time goes into framing the problem, wrangling the data and keeping the model alive in production. This section walks the whole lifecycle on one problem from the factory floor: predicting machine breakdowns before they happen. It's the same problem the Classification page uses to compare models. The failure people hit is starting at stage 5: a model with a great AUC that no decision depends on.

Six stages in a row: frame, explore, preprocess, features, train, deploy, with a loop from deploy back to exploreSix stages in a row: frame, explore, preprocess, features, train, deploy, with a loop from deploy back to explore

Figure L0-1: The six stages. Amber is framing, the stage this page owns. The dashed loop is what drift sends you back to.

Key concepts​

Stages at a glance​

StagePageThe one mistake that kills projects here
Frame the problemThis pageBuilding a model nobody asked a decision of
ExploreExploratory Data AnalysisPlots without decisions; a broken label found in week three
PreprocessData PreprocessingLeaking the future into training data
FeaturesFeature Engineering & SelectionAdding features instead of deleting them
Train & evaluateModel Training & EvaluationValidating on data the model couldn't have at prediction time
Deploy & monitorInference & ProductionShipping the model and walking away

Roughly 80% of a project is stages 1–4 and 6. A plan that gives most of the schedule to "modelling" is wrong.

The decision​

A model predicts; a project changes a decision. If no decision changes, don't build the model. Write the decision down first.

Goal statementResult
"Predict failures"❌ Fixes nothing: no metric, no cadence, no deliverable
"Every month, give the planners a ranked list of at-risk machines so they spend limited inspection hours on the right ones"βœ… Fixes the metric (precision and recall at a budget-driven threshold, per the threshold example), the cadence (monthly batch) and the deliverable (a list, not an API)

The label​

"Failed" sounds obvious and isn't.

A machine has failed if it has an unplanned breakdown at any point in the 30 days after the snapshot date. Planned maintenance stops don't count.

Every word is load-bearing.

Definition changeResult
Count planned stops as failures❌ The model learns the maintenance schedule
7-day window instead of 30A different problem: different base rate, different model
No snapshot date in the definition❌ No way to tell which data the model may use

The snapshot date​

The snapshot date is the moment you freeze time. Every feature uses only data from before it. The label comes only from the window after it. This rule prevents the most expensive bug in applied ML: leakage.

Three historical snapshots a month apart, each with a 90-day feature window before it and a 30-day label window after it, plus a scoring row today whose label is unknownThree historical snapshots a month apart, each with a 90-day feature window before it and a 30-day label window after it, plus a scoring row today whose label is unknown

Figure L0-2: How snapshot dates build the training set. Blue is the feature window, green is a known label, grey is a label not yet known. Amber lines are snapshot dates.

Training data is many historical snapshots, one row per machine per snapshot. Scoring is the same computation with today as the snapshot. Every later page refers back to this figure.

Is ML needed?​

Build the rule-based baseline first. The model must beat it to earn its complexity.

OptionStrengthUse it when
CMMS rule: active temperature alarm or over 5,000 hours since serviceExplainable, free, ships todayIt catches most breakdowns (here: PR-AUC 0.24)
ModelFinds interactions a rule can'tIt beats the rule by enough to pay for monitoring and retraining (here: 0.46)

Business metric and ML metric​

Agree the mapping up front. If you can't write it down, you'll ship a model with a great AUC that nobody uses.

SideMetricWho owns it
BusinessDowntime hours prevented per $1,000 of inspection budgetPlant manager
ModelPR-AUCData scientist
The bridgeThe decision threshold, set from inspection cost vs breakdown costBoth, together

The running example​

10,000 machines across the plant network, ~300 unplanned breakdowns per 30-day window (3%), with features from vibration, temperature, load cycles, service history and work orders.

StageWhat happens to the failure problem
EDAThe label audit, the failure-rate-by-segment chart, and the leak scan that should have caught the 0.99 bug
PreprocessingMissing oil-analysis scores, 24/7-line outliers, and the leaked column that scored AUC 0.99
FeaturesRolling sensor windows from the snapshot date, then deleting most of them
TrainingWhy random k-fold lies on this problem and a time-based split doesn't
ProductionMonthly batch scoring, drift after a rush order, and proving impact with a control group

This section owns the decisions. AI Engineering owns the serving code.

Gotchas​

  • Starting with a model. Without a written decision, nothing tells you what metric or cadence to build for. Write the goal statement first.
  • A label without a window. "Failed" with no time window can't be computed consistently. Fix the window and what counts.
  • Counting planned stops. The model learns your maintenance calendar. Exclude planned stops from the label.
  • Skipping the rule baseline. You can't show the model is worth its upkeep. Score the CMMS rule first.
  • No business-to-ML mapping. A good AUC doesn't become a decision. Agree how the threshold converts one into the other.

Scenario questions​

Q1 β˜… A plant manager asks you to "use AI to predict failures". What do you ask first?

Model answer
  • Clarify: what would you do differently with a prediction, and how often?
  • Observe: planners schedule inspections monthly, with a fixed budget of inspection hours.
  • Hypothesise: the real need is a ranked monthly list, not a real-time alarm.
  • Fix: write the goal statement: a monthly ranked list for limited inspection hours.
  • Prevent: no data work before the decision, label and metric are written down. The trade-off is a slower start.

Q2 β˜…β˜… How would you define the label for machine failure?

Model answer
  • Clarify: what counts as a failure, and how far ahead is useful for planners?
  • Observe: the CMMS records both planned stops and unplanned breakdowns.
  • Hypothesise: including planned stops would teach the model the maintenance schedule.
  • Fix: an unplanned breakdown within 30 days after the snapshot date.
  • Prevent: the definition lives in one written query, reviewed with the reliability engineers. The trade-off is a narrower label that ignores near-misses.

Q3 β˜…β˜…β˜… A simple rule already catches most breakdowns. Should you still build a model?

Model answer
  • Clarify: what does a missed breakdown cost, and what does the rule miss?
  • Observe: the rule scores PR-AUC 0.24; a quick logistic regression scores 0.31.
  • Hypothesise: a model pays off only if it clears the rule by enough to cover monitoring, retraining and on-call.
  • Fix: build a time-boxed model. Ship it only if it clearly beats the rule (here 0.46, about double).
  • Prevent: the rule stays as the fallback and the yardstick. The trade-off is maintaining two systems for a while.

Summary​

  • A project changes a decision. Write the decision first; it sets the metric, cadence and deliverable.
  • The label is a definition. Unplanned breakdowns, 30 days after the snapshot date, planned stops excluded.
  • The snapshot date freezes time. Features from before it, labels from after it, on every page that follows.
  • Beat the rule first. A model that can't clearly beat the CMMS query shouldn't ship.
  • Map business to ML. The threshold turns PR-AUC into downtime hours prevented.

Next β†’ Exploratory Data Analysis