Lawfare Academy

AI 301 — Machine Learning, Neural Networks and Language · Weeks 15–16

Model comparison, drift and deployment decisions

Full teaching sequence and cumulative subject work

Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Complete the assigned model-evaluation sections and a small source exercise from each model family. Use synthetic or openly licensed data and document its provenance.

Train a logistic model and expose a changed mechanism — primary material, constructed-response tasks, complete worked model and changed-case examination →

Deployment shift and a bounded release decision

Evaluation describes a model under a particular data-generation and decision setting. Feature checks can reject values outside a contract, while distribution shift can occur entirely inside those ranges. Monitor data, predictions and outcomes where outcomes become available, and specify actions for suspected degradation. A model version change can alter behavior even when application code is unchanged.

A release decision should compare a baseline, candidate performance, operational costs and failure cases. Preserve a fallback, record versions and use a rollback trigger tied to observed behavior. Absence of an alarm is not proof that the system remains valid.

Worked problem

A model is 94% accurate on an old process and 51% on fictional cases from a changed rule. All input values still pass the schema. Evaluate release readiness.

Trace the complete reasoning
  1. The schema confirms representation and range, not stability of the target relationship. Both measurements can be valid for different mechanisms.

  2. Investigate whether deployment now follows the changed process. If so, the old score does not establish current usefulness.

  3. Compare the candidate with simple baselines on the relevant new data and inspect errors, costs and subgroup patterns.

  4. Delay or restrict automated use when the deployment evidence is insufficient. Use a defined fallback and collect feedback rather than silently averaging the two accuracies.

Independent transfer problem

A monitored model has unchanged feature averages but worse outcomes. What should the investigation include?

Compare the transfer solution

Check conditional relationships, subgroup composition, label definition and delay, data-pipeline changes and decision thresholds. Equal marginal averages can hide changed relationships or offsetting subgroup shifts. Reproduce the evaluation with versioned inputs and targets, and do not dismiss outcome degradation because one feature summary is stable.

Learning objectives

  • Explain and trace the mechanisms in model comparison, drift and deployment decisions.
  • Apply the method to the worked example and changed-condition exercise.
  • Identify assumptions, failure cases and the evidence needed to justify a result.

Study the mechanism

A model is only one component of a deployed decision process. Inputs must be collected, transformed and checked; outputs must lead to a defined action; errors must be detected and handled. Evaluate the entire pipeline under realistic constraints. A model that improves an offline metric may add review work or fail on the cases most important to users.

Distribution shift changes the relationship between training evidence and deployment. Feature distributions can change, label prevalence can move and the relationship between inputs and outcomes can evolve. Monitor input quality and operational outcomes, but remember that labels may arrive late or only for selected cases. A shift alarm indicates a reason to investigate, not automatic proof that retraining will fix the problem.

A release needs a versioned model, preprocessing, feature schema, evaluation record and rollback plan. Keep a simple fallback for unavailable or out-of-scope inputs. Decide who can approve changes and which evidence triggers retirement. Compare total cost, including inference, data maintenance, review and incidents. If an intervention changes behavior, the data generated after deployment may differ from passive historical data. Treat release as an ongoing empirical responsibility rather than an endpoint reached by one benchmark.

Worked example

def within_scope(record):
    return (record.get("currency") == "USD"
            and type(record.get("hours")) is int
            and 0 <= record["hours"] <= 80)

assert within_scope({"currency": "USD", "hours": 8})
assert not within_scope({"currency": "EUR", "hours": 8})

The guard rejects a currency or hours representation outside the documented model contract. It is only an example of input scope, not a complete drift detector. A value can pass the schema and still be unlike the training population. Log a minimal rejection reason, provide a safe fallback and review rejection patterns without exposing raw confidential records.

Check your understanding

What is required beyond a strong offline score?

  1. A validated workflow, monitored outcomes and a recovery policy
  2. Immediate unrestricted deployment
  3. A promise that distributions will remain fixed
Answer and reasoning for every option

Correct: A validated workflow, monitored outcomes and a recovery policy The system must remain useful under actual operating conditions.

Reconsider: Immediate unrestricted deployment Scope and consequences still require a bounded deployment decision.

Reconsider: A promise that distributions will remain fixed Future data can change despite strong historical performance.

Transfer laboratory: A model update without application changes

A hosted model version changes while application code remains identical. Explain why previously passing checks may need to run again.

Work through the full solution

Output behavior, latency, tokenization, tool selection and failure rates can change independently of application code. Version the complete system configuration, rerun representative and adversarial evaluations and compare case-level regressions. Keep a fallback and an approval policy for consequential changes. A provider’s aggregate benchmark is not a substitute for this workflow’s evidence.

Evidence of understanding

Treat the model and prompt as versioned dependencies and define rollback/fallback criteria.

Complete on-site teaching readings

These are full attributed source sections, not previews. Read them alongside the original Academy explanation and code.

  1. 4.7. Environment and Distribution Shift Open the notebook in SageMaker Studio Lab · Aston Zhang, Zachary C. Lipton, Mu Li and Alexander J. Smola
  2. 19.1. What Is Hyperparameter Optimization? Open the notebook in SageMaker Studio Lab · Aston Zhang, Zachary C. Lipton, Mu Li and Alexander J. Smola
  3. 3.4. Metrics and scoring: quantifying the quality of predictions · The scikit-learn developers
  4. 11. Model persistence · The scikit-learn developers
  5. 10.1. Strategies to scale computationally: bigger data · The scikit-learn developers

Open in My Learning to record progress →