Block 79: Saving & Loading Models
Persist trained models for later use without retraining.
Concepts
- joblib.dump() and joblib.load()
- pickle module as alternative
- Saving entire Pipeline objects
- Versioning models with filenames
Code Examples
See exercise below.
Exercise
Train a model, save it with joblib. Load it in a new script and make predictions. Verify results match. Save and load a full Pipeline (scaler + model) and verify predictions are identical.
Homework
What information besides the model file do you need to save to reproduce a deployment? List 5 things.