Machine-learning pipelines are software, and like all software they can contain bugs — transformations that produce wrong outputs, pipelines that behave differently on edge-case inputs, or models that silently accept the wrong number of features. Testing pipelines with pytest exists to catch these bugs before they reach production, providing the same automated quality assurance for data-science code that software engineers take for granted. Without tests, every pipeline change risks introducing silent regressions that only surface in production when they have already caused damage, and the pipeline's correctness is known only by running it manually and inspecting the output. With tests, regressions are caught immediately, the pipeline's expected behaviour is documented in executable form, and confidence in deploying changes is dramatically higher — exactly the professional standard that production ML systems require.
25 minintermediate
Testing ML Pipelines with pytest
Analogy🏏Cricket
🏏 Think of it like cricket: Reducing twenty batting statistics to two dimensions with PCA produces a flat projection that may look like one undifferentiated cloud, while t-SNE or UMAP finds that the data actually organises into distinct clusters — aggressive pinch-hitters, steady anchors, explosive finishers — whose separation PCA's flat projection smeared together. Just as the non-linear reduction reveals the natural groupings that flat projection could not, t-SNE and UMAP reveal structure that PCA misses because it can only flatten, not curve to follow the data's natural shape. The insight is that non-linear reduction methods follow the data's true curved geometry rather than forcing a flat projection, revealing the cluster structure and local neighbourhoods that linear methods like PCA cannot preserve.
Lesson 29 of 35
0% complete