You want to deploy your scikit-learn model. Now what? You can make an API for your model in Jupyter! You’ll learn FastAPI, a Python web framework with automatic interactive docs. We’ll validate inputs with type hints, and convert to a dataframe, to make new predictions with your model. You’ll have a working API prototype, running from a notebook and ready to deploy!
This talk is for people who feel comfortable in notebooks and can fit scikit-learn models. It’s about the technical process in-between developing your model and deploying it. Maybe you’ve never deployed an API before, or maybe you’ve tried Flask but you’re curious about FastAPI.
We’ll use Binder to open a complete notebook with a model that’s already been fit. We’ll introduce FastAPI step-by-step, live coding in our notebook. First, we’ll create an API route that returns random predictions. We’ll run a web server from our notebook and see how FastAPI automatically generates interactive docs.
Next we’ll add our scikit-learn model to make real predictions. We’ll create a class with type hints to validate the model inputs. We’ll convert the data to a pandas dataframe with the right shape for our model’s predict method. Jupyter helps us do this iteratively and interactively.
Now you have a working API prototype, running from a notebook and integrated with a web app! You’re ready to deploy to cloud platforms like Heroku. I’ll provide written instructions to guide your next steps.