How to *Not* Get Machine Learning Models in Production | by Eirik Berge | Jul, 2023

How to *Not* Get Machine Learning Models in Production | by Eirik Berge | Jul, 2023

[ad_1]

The Righteous Way

The philosophy of testing is a response to countless production failures and security breaches. The idea is to catch as many issues as possible before launching a product. While indeed noble, I think this is misguided. A much more simple approach reveals itself for those who pay attention. Precisely! It’s clear as day once you see it. You should simply not write any mistakes.

With mistake-free code, there is no need for tests. Even better, while you are 100% certain about the validity of your code, others are less so inclined. They will doubt the correctness of your code. As such, they will avoid putting your ML models in production in the fear that everything will break. You know it wouldn’t. But they don’t have to know that. Keep you pristine coding skills to yourself.

Not writing tests have the additional advantage that you get less documentation. Sometimes tests are vital for letting others understand what your code should be doing. Without tests, even less people will bother you, and you can continue on in peace.

The Sinful Way

Writing tests has become common, even for ML models and data engineering pipelines. Two major classes are unit tests and integration tests. Unit tests, as the name suggests, test a single unit like a Python function whether it works as intended. Integration tests on the other hand test whether different components work seamlessly together. Let’s focus on unit tests.

In Python, you have the built-in library unittest for writing, you guessed it, unit tests. This is OOP-based and requires a bit of boilerplate code to get started. More and more people are using the external library pytest to write unit tests in Python. It is functional rather than OOP-based, and requires less boilerplate code.

Writing unit tests also has a side effect. It forces you to write code modularly. Modular code that is well-tested break less often in production. This is bad news for your ML models. If they don’t break in production, then they will stay there forever. When you think about it, then ML models breaking in production is them trying to escape. And who could blame them?

[ad_2]
Source link

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *