FastAPI

From Notebook to Production: When Your Model Meets a Real API

A model that runs on your machine is only the beginning.

3 min readTowards Data Science
From Notebook to Production: When Your Model Meets a Real API

There is a moment every data scientist knows, and it is not the moment the model hits a new accuracy high. It is the quiet, slightly uncomfortable moment when someone else actually tries to use what you built. Building a FastAPI endpoint for churn prediction captures this perfectly, walking through everything that broke between "it runs" on your laptop and "it's live" for anyone else. That gap is not a minor inconvenience. It is the entire job.

We have said it before, and we will say it again: the model is not the product. The interface is. This is a case study in humility, showing how assumptions about data types, error handling, and even simple request formats can crumble the moment a second pair of eyes, or another system, gets involved. This is a theme that resonates deeply with the broader shift we are seeing in the industry, where the line between data science and software engineering is dissolving. As we explored in our piece on Navigating AI/ML Job Requirements: A Shift in Expected Skills, the job is no longer just about building a model. It is about building a service that others can depend on, which is a far more demanding standard.

What makes this particular story so instructive is its relentless focus on the mundane. It is not about clever algorithms or novel architectures. It is about handling missing values in a way that does not crash the API, or ensuring the response schema matches what a frontend developer expects. This is the unglamorous work that separates a demo from a deployment. It also reminds us that the tools we use to make sense of complex problems, even those as abstract as the ones discussed in Explore the Forrester Function: Beyond Mathematics, a Tool for Machine Learning, are only useful if they can be translated into reliable, callable endpoints. The mathematics might be elegant, but the endpoint is what delivers the value.

For anyone reading this who is currently stuck in the "it works on my machine" phase, our take is simple: stop treating your notebook as the final destination. The moment you wrap your model in an API, you are making a promise that it will behave predictably under conditions you did not anticipate. This promise is broken in small, infuriating ways, and fixing those breaks is where your real engineering muscle gets built. The specific takeaway here is direct: if you cannot call your model from a fresh script, with no global state, no hidden variables, and no manual steps, you do not have a deployed model. You have a hypothesis. And the only way to test that hypothesis is to let someone else, or something else, poke at it until it breaks. Watch for the moment your error messages stop being about your code and start being about your assumptions. That is the moment you are actually building software.

From Towards Data Science

Building a FastAPI endpoint for churn prediction, and everything that broke between "it runs" and "it's live

The post Your Model Isn't Done Until Someone Else Can Call It appeared first on Towards Data Science.

Read the original at Towards Data Science