Ship Your First Model: From Notebook to a FastAPI Service
Who it is for
What you will achieve
Prerequisites
Curriculum
- Step 1: Saving and Loading Models with joblib: One Pipeline, One File
Train the rain pipeline once, seal it in a 4,298-byte file with joblib.dump, load it in a fresh program with the same 0.831 accuracy, avoid the 2D-array error and pin the versions in requirements.txt.
- Step 2: FastAPI Hello World: Routes, uvicorn and the Free Swagger Page
The smallest FastAPI app: two routes in main.py, started with uvicorn. Follow one request from the browser to the route table and back as JSON, see a 404, and try the routes on the free Swagger page at /docs.
- Step 3: Deploy a Machine Learning Model with FastAPI: POST /predict for a Saved Model
Put the saved rain model behind a web address: load model.joblib once, check five inputs with a Pydantic class, answer POST /predict with Yes and 0.63, and watch a bad value get a 422 before the model ever runs.
- Step 4: Project: Car Price Predictor End to End, from CSV to a FastAPI Price API
The whole ML workflow on 205 cars: clean the brand out of CarName, split first, audition five regressors on the same folds, tune the random forest, test once (RMSE 2,195, R2 0.939), save it and serve prices with FastAPI.
- Step 5: Python Virtual Environments: One Project, One Toolbox
Why every Python project gets its own virtual environment: two projects that need different versions of requests, python -m venv .venv, activation, pip install and the PyCharm setting that activates it for you.
- Step 6: Git and GitHub Fundamentals: Commits, Branches, Push and Pull
The Git you use every day, on a tiny hello-ml project: commits as save points, the staging area, a branch merged with a fast-forward, then push, clone, pull and pull requests with a teammate.
- Step 7: Testing a FastAPI App with pytest: Three Small Tests
A tiny FastAPI app with a Hello World route and a name route that refuses numbers, three pytest tests that check it, and what happens when the validation is deleted by mistake.
- Step 8: Config and Logging Instead of Hard-Coded Values in ML Training
Take the hard-coded values out of a car price training script: one config.toml read with tomllib, logging with levels and a run id on every line, and secrets read from the environment. Same RMSE, 2195, before and after.
- Step 9: SQL Essentials for Python: SELECT, WHERE, JOIN and GROUP BY
The SQL a Python developer needs, on a tiny shop with four customers and eight orders: CREATE TABLE, INSERT with placeholders, SELECT with WHERE, JOIN, GROUP BY, pandas.read_sql, and why values never go in f-strings.