Week 7 • Friday

Block 69: Wrapping ML Models as APIs

Serve a pre-trained ML model as an API endpoint.

Concepts

Code Examples

See exercise below.

Exercise

Train a simple Iris classifier with scikit-learn, save it, and serve predictions via a FastAPI endpoint that accepts sepal/petal measurements. Test it with valid and invalid inputs.

Homework

What additional concerns arise when deploying an ML model as an API vs a static data API?