Model Persistence
Learn how to export scikit-learn models so that we can load and reuse them.
We'll cover the following
Model persistence refers to the ability to save trained ML models to disk and reload them later for reuse. It allows us to store the model’s learned parameters, trained weights, and other necessary information in order to use it again without retraining.
Model persistence is crucial in various scenarios, such as deploying a trained model in a
Exporting and importing models provide several advantages:
Reusability: Exported models can be reused on new data without the need for retraining, saving time and computational resources.
Reproducibility: Models can be shared with others, enabling them to reproduce and validate the results or make predictions using the same model.
Deployment: Exported models can be deployed in production systems, making predictions on new data in real-time.
Model persistence in practice
Just like any other type of data, model persistence works by saving and loading files, which we do via the Joblib
library.
It’s important to note that Joblib
is not a part of scikit-learn itself, but we include it in our toolkit because it’s an invaluable tool to learn and it seamlessly complements scikit-learn.
Let’s see how to export and import a trained scikit-learn model using the Joblib
library:
Get hands-on with 1200+ tech skills courses.