Training and optimization
Capstone: Design, Run, Diagnose, and Defend a Training Program
Design a complete training program for a rare-event, multi-output forecasting system and defend every objective, update, checkpoint, and stop decision.
By the end you can
- Translate a deployment problem into objectives, metrics, constraints, and a training contract
- Choose optimizer, schedule, batching, precision, regularization, and checkpoint policies as one coherent system
- Design diagnostics that localize data, numerical, optimization, and generalization failures
- Produce a decision memo that can justify continuation, rollback, deployment, or redesign
Example
The assignment: predict battery risk before service disruption
A commercial fleet operates electric delivery vehicles across climates and routes.
- Input: Thirty days of irregular telemetry, charging events, ambient conditions, maintenance history, and vehicle metadata.
- Outputs: A seven-day failure-risk score, a time-to-service estimate, and an optional abstention signal.
- Reality: Confirmed failures are rare, labels arrive late, and maintenance actions alter what is later observed.
- Constraint: The service queue can inspect only two percent of vehicles each day, with stricter limits in remote depots.
- Cost: Missed failures disrupt routes; unnecessary inspections consume technicians and replacement parts.
- Deployment: Weekly batch scoring must finish overnight and provide evidence for prioritized review.
Comparison
Symptoms and the first discriminating test
The first action should separate competing causes rather than change several knobs.
Risk head predicts almost nothing
Could be imbalance, masking, or a collapsed threshold.
- Check positive counts after sampling
- Inspect unreduced per-class loss
- Overfit a balanced tiny subset
- Verify logits before thresholding
Time estimate oscillates
Could be outliers, target scale, or an excessive rate.
- Plot target distribution
- Compare robust and squared loss
- Inspect gradient contribution by head
- Lower only the relevant group rate
Validation improves then reverses
Could be overfitting, shift, or checkpoint noise.
- Inspect learning curves by depot
- Repeat neighboring checkpoints
- Compare later temporal windows
- Test stronger targeted regularization
Distributed run disagrees with one GPU
Could be reduction, sampling, or state synchronization.
- Match one global batch exactly
- Check all-reduce and loss normalization
- Audit sharding duplicates
- Compare buffers and RNG state
Key idea
Do not optimize the validation set through endless iteration
Every architecture choice, sampling change, schedule tweak, and checkpoint selection spends part of what validation can still tell you. Repeatedly choosing the best result turns the validation set into part of the training process.
The most serious attempt to measure that cost did not argue about it. It rebuilt the benchmarks. In 2019 four researchers re-ran the original collection procedures for CIFAR-10 and ImageNet, built fresh test sets, and scored the existing models on them: “We evaluate a broad range of models and find accuracy drops of 3% - 15% on CIFAR-10 and 11% - 14% on ImageNet.” Nothing about those models had changed. The test set had.
Note what happened next, because it is the honest half of the story. An independent MIT group reanalysed the same ImageNet replication in 2020. After correcting statistical bias in the replication procedure, only an estimated 3.6% ± 1.5% of the original 11.7% ± 1.0% drop was left unaccounted for. Two careful teams, one benchmark, and still an open argument over how much of the gap is adaptive overfitting and how much is simply harder data.
If the size of that effect is contested on a public benchmark scored by thousands of models, no internal fleet project will settle it by intuition. Keep a selection log. Limit the search space. Reserve a final temporal holdout or shadow evaluation for the chosen program. Otherwise confidence will be overstated.
Model selection has an evidence budget even when no gradient touches the validation examples.
Comparison
A ladder of baselines before a complex sequence model
Every added component should defeat a simpler alternative under the same temporal protocol. On this kind of data the classical rung is not a courtesy rung.
Across a standard set of 45 tabular datasets, tree-based models such as XGBoost and Random Forests were still state of the art on medium-sized data of roughly 10,000 samples. That benchmark was published in 2022, and its authors released the hyperparameter search behind it: 20,000 compute hours of raw results per learner. The same conclusion came independently from Shwartz-Ziv and Armon, testing on the deep models’ own ground: “Our study shows that XGBoost outperforms these deep models across the datasets, including the datasets used in the papers that proposed the deep models.” XGBoost also required much less tuning, which is the second cost the fine-tuned rung has to absorb.
Thirty days of telemetry aggregated into engineered windows is exactly the terrain both benchmarks describe. The boosted baseline is the number the sequence model has to beat, not the number it is shown next to for form.
Operational heuristic
Rank by recent diagnostic alarms and battery-age rules.
- Fast to implement
- Auditable by technicians
- Weak interaction modeling
- Essential product baseline
Classical tabular model
Aggregate windows and fit a boosted or linear baseline.
- Strong on engineered summaries
- Low serving cost
- Limited temporal detail
- Useful leakage detector
Frozen pretrained encoder
Reuse representations and train new output heads.
- Reduces update risk
- Tests transfer value
- May miss fleet-specific dynamics
- Supports staged fine-tuning
Fine-tuned temporal model
Adapt the encoder with task-specific heads and schedule.
- Highest capacity
- Needs careful regularization
- Largest compute and drift burden
- Must earn complexity
Case
Eighteen neural recommenders, seven reproducible, six beaten by heuristics
A ladder of baselines is not a formality, and one audit shows why. Ferrari Dacrema, Cremonesi and Jannach went through the neural recommenders presented at top venues and reported the result at RecSys in 2019. They “considered 18 algorithms that were presented at top-level research conferences”. “Only 7 of them could be reproduced with reasonable effort.” Of those seven, six “can often be outperformed with comparably simple heuristic methods”. The seventh beat the baselines but did not consistently beat a well-tuned non-neural linear ranking method.
No optimizer was at fault in any of those cases. Build the ladder before the sequence model rather than after it.
Figure
Freeze the problem before choosing the optimizer
Define the scoring timestamp, prediction horizon, unit of analysis, label delay, exclusions, and what information exists at decision time. Separate training labels from the actions that maintenance teams took after earlier scores. The model contract also specifies the three output heads, acceptable latency, queue policy, and abstention behavior. Any change to these elements creates a new experimental question.
Leakage is the most thoroughly surveyed failure in applied machine learning. Kapoor and Narayanan surveyed it across disciplines in Patterns in 2023. They “find 17 fields where leakage has been found, collectively affecting 294 papers”. Their taxonomy names “eight types of leakage” running “from textbook errors to open research problems”. They also re-ran one case in detail: civil war prediction. Once the errors were corrected the complex models “do not perform substantively better than decades-old LR models”.
A scoring timestamp is what keeps that outcome away from this project.
The most expensive optimizer cannot rescue a moving or leaked target.
Steps
Prepare the final defense package
The submission should let another team reproduce the reasoning, not merely rerun code. The first two items are the ones teams treat as classroom ceremony. They are also the two a regulator now asks for by name.
The FDA's final guidance of December 2024 tells manufacturers of AI-enabled device software what a predetermined change control plan has to contain: “This guidance recommends that a PCCP describe the planned AI-DSF modifications, the associated methodology to develop, validate, and implement those modifications, and an assessment of the impact of those modifications.” The incentive is exact. Changes made in line with the pre-authorised plan can be made without a new marketing submission.
A charter written before the runs, and a contract that records what was actually trained, buy the same thing here — the right to change the system later without relitigating the whole evaluation.
1. Experiment charter
State hypotheses, baselines, metrics, constraints, budget, and stop rules.
2. Training contract
Record data, targets, model, losses, optimizer groups, schedule, precision, and state.
3. Evidence notebook
Present curves, gradient diagnostics, slices, examples, ablations, and failed runs.
4. Checkpoint rationale
Explain why the selected state beats alternatives under the operational policy.
5. Risk register
List unresolved uncertainty, sensitive slices, drift risks, and required safeguards.
6. Decision memo
Recommend deploy, shadow, continue, redesign, or stop with explicit conditions.
Visual
An objective stack for three outputs
The training signal must preserve each task without hiding operational priorities. The evaluation row is where that discipline is won or lost, because on rare events the familiar summaries stay flat while decision quality collapses.
A worked example published in PLOS ONE in 2015 makes the gap visible. Accuracy is 0.6 on both the balanced and the imbalanced sample. Precision falls from 0.6 to 0.33. Saito and Rehmsmeier's reason for preferring precision-recall plots on skewed data is stated in the abstract: “We show here that the visual interpretability of ROC plots in the context of imbalanced datasets can be deceptive with respect to conclusions about the reliability of classification performance, owing to an intuitive but wrong interpretation of specificity.”
The formal version had already been proved in 2006 by Davis and Goadrich: a curve dominates in ROC space if and only if it dominates in PR space, and an algorithm optimising area under the ROC curve is not guaranteed to optimise area under the PR curve.
Confirmed failures in this fleet are rare and the queue is capped. So the evaluation suite is written as PR curves and recall at queue capacity, not as an average the training loss can quietly satisfy.
Fleet outcome
Reduce preventable disruptions without overwhelming service capacity.
Decision policy
Rank vehicles, enforce depot limits, and route uncertain cases to review.
Evaluation suite
PR curves, recall at queue capacity, lead-time error, calibration, and depot slices.
Model outputs
Failure risk, service-time distribution, and abstention or uncertainty signal.
Training objectives
Weighted classification, robust time loss, and a validated uncertainty surrogate.
Example
A defensible initial optimization recipe
The numbers are starting hypotheses, not universal defaults.
- Optimizer groups: AdamW with lower learning rate for the pretrained encoder and a higher rate for newly initialized heads.
- Schedule: Short warmup followed by decay, with total update count defined after effective batch size and accumulation are fixed.
- Batching: Length-aware batches with depot-balanced sampling and explicit measurement of duplicate vehicles across workers.
- Precision: Mixed precision with finite-gradient checks, logged loss scale, and full-precision treatment for fragile reductions.
- Regularization: Moderate decay, targeted dropout, realistic sensor corruption, and early stopping on queue-constrained validation evidence.
- Checkpointing: Save model, optimizer, scheduler, scaler, sampler, RNG state, data version, and evaluation configuration.
Analogy
A flight-test campaign for a new aircraft configuration
New aircraft do not reach certification on a convincing final flight. They reach it by accumulating an amount of evidence that federal law fixes in advance. Under 14 CFR §21.35(f) the function-and-reliability flight tests must include, in the words of the rule, “For aircraft incorporating turbine engines of a type not previously used in a type certificated aircraft, at least 300 hours of operation with a full complement of engines that conform to a type certificate”. For all other aircraft the minimum is 150 hours.
Those flights may not begin at all until §21.35(a) is satisfied: structural compliance shown, ground inspections done, conformity to the type design established, and a signed flight-test report in hand. The same two thresholds appear verbatim in the European and UK Part 21 rules. Two regulators priced the same evidence at the same number, independently.
None of those gates can be skipped and then reconstructed afterwards from the final result. The 300 hours cannot be inferred from a good landing. A training program earns its final run the same way — staged evidence, preserved records, and no-go criteria written before anyone knows which way they will cut.
A final run is convincing only when a chain of earlier tests makes its outcome interpretable.
Visual
The review board needs six forms of evidence
A model card alone cannot carry the decision. Operational fit is the step that a strong-looking model most often fails.
The Epic Sepsis Model, a proprietary score deployed at hundreds of US hospitals, was validated externally across 38,455 hospitalizations at Michigan Medicine and reported in JAMA Internal Medicine in 2021. Its area under the ROC curve was 0.63 (95% CI, 0.62–0.64). The number that decided its usefulness was not the AUC: “The ESM also did not identify 1709 patients with sepsis (67%) despite generating alerts for an ESM score of 6 or higher for 6971 of all 38 455 hospitalized patients (18%), thus creating a large burden of alert fatigue.” It missed 1,709 of 2,552 sepsis patients while alerting on nearly a fifth of everyone admitted.
An independent 2024 validation at two Harris County, Texas emergency departments found a sensitivity of 14.7% and a positive predictive value of 7.6% for sepsis within six hours.
Read that against this fleet's constraint. A scorer that flags 18% of the fleet cannot be run by depots that can inspect two percent, whatever its curves look like in the notebook.
1. Validity
Point-in-time data, label policy, splits, and absence of known leakage.
2. Learnability
Tiny-subset tests, baseline comparisons, and stable optimization traces.
3. Generalization
Temporal windows, depot slices, seeds, and rare-event uncertainty.
4. Operational fit
Queue capacity, latency, calibration, abstention, and human workflow.
5. Efficiency
Training cost, throughput, memory, serving budget, and retraining cadence.
6. Reversibility
Checkpoint provenance, rollback state, monitoring triggers, and ownership.
Steps
Write the training plan as a sequence of gates
Do not launch the final run until each earlier gate produces credible evidence.
- 1
Gate 1: Data audit
Verify point-in-time features, delayed labels, depot coverage, and duplicate vehicles.
- 2
Gate 2: Tiny overfit test
Fit a small clean subset and inspect each output head and mask.
- 3
Gate 3: Baseline ladder
Measure heuristics, tabular models, and frozen representations on rolling splits.
- 4
Gate 4: Stable fine-tuning
Use discriminative learning rates, warmup, mixed precision checks, and bounded gradients.
- 5
Gate 5: Capacity-aware selection
Choose checkpoints by queue-constrained metrics and calibration, not minimum loss alone.
- 6
Gate 6: Repeated confirmation
Repeat finalists across seeds and later time windows before operational review.
The standard is a defendable decision, not a perfect curve
A strong capstone may conclude that the temporal model does not justify its complexity, that labels are too selective, or that depot coverage prevents a fair launch. Those are successful findings when supported by disciplined evidence.
The most expensive version of that conclusion was reached by a board rather than by a researcher. On 2 November 2021 the board of Zillow Group decided to wind down Zillow Offers, the home-buying business whose pricing forecasts drove purchases. The company had bought homes above its own estimates of future selling prices. It recorded a $304.4 million inventory write-down for the quarter ended 30 September 2021, expected a further $240–265 million of charges in the fourth quarter, and cut roughly 25% of its workforce.
The reasoning given to shareholders was not about a model that could be tuned: “Ultimately, we determined that further scaling up Zillow Offers is too risky, too volatile to our earnings and operations, provides too little opportunity for return on equity, and serves too narrow a portion of our customers.” Risk, volatility, return and scope. That is the vocabulary a capstone memo should also be able to speak.
The final judgment should explain what was learned, what remains uncertain, and which next action has the highest expected value. Training excellence includes knowing when not to continue.
A trustworthy program can defend both the model it selected and the experiments it refused to run.
Key takeaways
- The capstone begins with scoring time, unit of analysis, label policy, decision capacity, and deployment constraints before any optimizer is selected; Kapoor and Narayanan found 17 fields where leakage has been found, collectively affecting 294 papers.
- A baseline ladder separates gains from data design, representation reuse, and full fine-tuning: of the 18 neural recommenders audited at RecSys in 2019, only 7 could be reproduced with reasonable effort and 6 of those were often beaten by comparably simple heuristic methods.
- Multi-output training requires explicit reduction, weighting, masking, gradient inspection, and metrics for each head, chosen so that rare events cannot hide — accuracy held at 0.6 in Saito and Rehmsmeier's example while precision fell from 0.6 to 0.33.
- Training gates should progress from data validity and tiny overfit tests to stable fine-tuning, capacity-aware selection, and repeated confirmation, in the spirit of 14 CFR §21.35, which fixes 300 hours of turbine operation and forbids flight testing before structures, ground tests, conformity and a signed report.
- Final evidence must cover validity, learnability, generalization, operational fit, efficiency, reversibility, and unresolved risk: the Epic Sepsis Model reached an AUC of 0.63 and still alerted on 18% of 38,455 hospitalizations while missing 67% of sepsis patients.
- A gold-standard training program can justify deployment, continued experimentation, redesign, or stopping with the same level of rigor, as Zillow Group's board did on 2 November 2021 with a $304.4 million write-down.