Skip to main content

ML development risks and mitigations

Why This Matters

Not every ML defect lives in the data or the model. The framework can have a bug in its evaluation code, the data split can leak, the deployment build can change the model, the hyperparameters can be chosen badly. These are risks in how the model was built and shipped, and they are tested with familiar tools: reviews, smoke tests, API tests, A/B and back-to-back testing.

What you will learn

  • The risks that come from ML development tools, configuration choices and deployment
  • Which test approach mitigates each
  • Where you have already met these risks in this course

Syllabus: AI-7.1.1.

Development risks and mitigations

ML development testing focuses on the tools, configuration choices and deployment mechanisms, not on the model itself.

Development riskTest approachWhere you saw it
Incorrect use of a library or framework APIAPI testing
Sub-optimal framework selectionFramework suitability reviewlesson 3
Unfairness introduced by the algorithm or frameworkTesting for biaslesson 35
Defective installation or buildSmoke testinglesson 52
Defective evaluation code in the frameworkReview the evaluation code; cross-check against manual benchmarkslesson 19: the library’s metrics checked against the formulas
Slow frameworkPerformance testing
Poor framework usabilityUsability testing
A defect in a framework library, or a defective algorithm implementationML functional performance testing, back-to-back testinglessons 44, 49
Security issues in the frameworkSecurity testing
Poor framework documentationDocumentation review
Sub-optimal algorithm selectionAlgorithm suitability review, A/B testinglesson 20
Sub-optimal hyperparameters (network structure, learning rate)ML functional performance testing, A/B testinglessons 16, 48
Defective split into training, validation and test dataData allocation reviewlesson 16: duplicates in both sets
Poor evaluation approach (for example how k-fold cross-validation is set up)ML functional performance testinglesson 16
Misreading results because of stochastic learningML functional performance testinglessons 26, 44
A deployment defect from generating a platform-specific versionSmoke testing, ML functional performance testing, A/B testinglesson 52
Model incompatible with the operational environmentSmoke testing, MLS deployment testinglesson 52
The new model is no better than the current oneShadow testinglesson 52

Three worth a closer look

Defective evaluation code. Every number you report comes from evaluation code: yours or the framework’s. If precision and recall are swapped (lesson 19 showed how easily that happens with confusion_matrix(...).ravel()), every decision based on them is wrong. Cross-check the library’s output against a manual calculation on a small example.

Misreading stochastic results. Training involves randomness: random starting weights, random data shuffling, random splits. Train the same model twice and the scores differ. A team that runs one training of model A and one of model B and picks the higher score may be choosing noise. Repeat training runs, or fix the random seeds and report the spread.

Data allocation. Records of the same customer, or duplicates, in both training and test data make test results too optimistic (lesson 16). A review of how the data was split, and a test like test_test_data_is_independent, catches it.

Exercise

Match each situation to a development risk and a test approach.

  1. A team cannot reproduce last month’s model: retraining on the “same” data gives 3 points lower accuracy.
  2. After converting a model for a mobile app, it crashes on older phones.
  3. Two data scientists each ran one training of their candidate model and chose the one with 0.5% higher accuracy.
  4. The test score is 98%, but the test data contains transactions from the same customers as the training data.
Show suggested answer
  1. Possibly stochastic learning or unversioned data/configuration. Approaches: ML functional performance testing with repeated runs and fixed seeds; a configuration management review of data and code versions (lesson 36).
  2. Model incompatible with the operational environment / deployment defect: smoke testing and MLS deployment testing on the target devices (cross-device testing, lesson 52).
  3. Misreading results because of stochastic learning: repeat the training several times and compare the distributions (ML functional performance testing), or an A/B test with a significance test.
  4. Defective data split: data allocation review; split by customer, not by transaction.

Exam-style questions

Quiz

1. Which test approach mitigates the risk that a newly trained model is no better than the model in production?

  • A. Installability testing
  • B. Shadow testing
  • C. Label correctness testing
  • D. Neuron coverage
Show answer
B.
Quiz

2. A framework’s built-in function for calculating recall might be defective. What is the recommended mitigation?

  • A. Use a different programming language
  • B. Review the evaluation code and cross-check the results against manual benchmarks
  • C. Stop calculating recall
  • D. Increase the training data
Show answer
B.