# Testing for Data Science: boosting ML reliability with Great Expectations

- Speaker: [Rachel Abo](/wiki/speakers/rachel-abo.md)
- Event: [Reversim Summit 2024](/wiki/years/2024.md)
- Video: https://www.youtube.com/watch?v=wlP-e-GMCCw
- Transcript: [/transcripts/2024/55-wlP-e-GMCCw.md](/transcripts/2024/55-wlP-e-GMCCw.md)
- Language: Hebrew · Type: talk · Level: intermediate
- Topics: [Machine Learning](/wiki/topics/machine-learning.md), [MLOps](/wiki/topics/mlops.md), [DevOps](/wiki/topics/devops.md), [Data Science](/wiki/topics/data-science.md)

> Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.

## Summary

The speaker discusses the challenges of writing tests for machine learning systems, which differ significantly from traditional software testing due to the stochastic nature of models and the complexity of data. To address this, the speaker introduces expectation testing for data validation and demonstrates practical techniques for testing training processes and model behavior using regression and benchmarks. Ultimately, adopting these testing practices helps data scientists catch bugs early, automate pipelines, and meet professional engineering standards. Listeners learn how to apply structured testing frameworks to improve ML reliability and development speed.

## Key points

- [1:09](https://www.youtube.com/watch?v=wlP-e-GMCCw&t=69s) The speaker shares a personal mistake where a flawed sampling method accidentally excluded risky merchants from the training data, leading to a wasted model.
- [5:17](https://www.youtube.com/watch?v=wlP-e-GMCCw&t=317s) Unlike traditional software with deterministic compilation, machine learning systems involve data, training processes, and stochastic models, making them much harder to test.
- [7:24](https://www.youtube.com/watch?v=wlP-e-GMCCw&t=444s) Expectation testing involves defining data expectations and constraints, allowing data scientists to validate static datasets and incoming production data automatically.
- [13:16](https://www.youtube.com/watch?v=wlP-e-GMCCw&t=796s) Practical data tests in internal pipelines include checking for duplicate records and ensuring smart filters properly limit over-represented repeat customers.
- [15:35](https://www.youtube.com/watch?v=wlP-e-GMCCw&t=935s) Statistical tests like the chi-squared test can verify that sampled data maintains proper proportions compared to the original dataset across different business categories.
- [19:00](https://www.youtube.com/watch?v=wlP-e-GMCCw&t=1140s) Training tests, such as overfitting a small model on a small dataset or monitoring epoch duration, act as smoke tests to catch fatal bugs early.
- [21:18](https://www.youtube.com/watch?v=wlP-e-GMCCw&t=1278s) Model regression testing compares new models against a trusted benchmark using statistical tests like the Kolmogorov-Smirnov test and specific edge-case examples.
- [24:40](https://www.youtube.com/watch?v=wlP-e-GMCCw&t=1480s) Integrating tests into a continuous integration system automates the validation process and establishes a shared language between developers and data scientists.

## Takeaways

- Apply expectation testing to validate data distributions, uniqueness, and feature constraints before training models.
- Use smoke tests like small-scale overfitting and training time limits to catch fatal pipeline errors early.
- Compare new models against established production benchmarks using statistical distribution tests and specific edge-case examples.

## Questions this talk answers

- How do you test machine learning data when data is non-deterministic and heavily imbalanced?
- What are effective ways to catch bugs in the model training phase before wasting computing resources?
- How can you perform regression testing on a newly trained machine learning model against a production benchmark?

## Technologies

Great Expectations

## Tags

continuous integration, data science, data validation, machine learning testing, mlops, model reliability, python
