Training can be slow, and production needs the same model that was validated. Persisting a fitted pipeline lets you train once and reload instantly — the bridge from notebook to application.
joblib
import joblibjoblib.dump(pipe, "model.joblib") # save the fitted pipelinemodel = joblib.load("model.joblib") # reload later / in productionmodel.predict(new_data) # includes all preprocessing
Key takeaways
- 01joblib.dump/load persist a fitted model or pipeline to disk.
- 02Save the whole pipeline so preprocessing travels with the model.
- 03Pin scikit-learn versions — pickles aren't guaranteed across versions.
- 04Never load a model from an untrusted source (arbitrary-code risk).
