How to Save Gradient Boosting Models with XGBoost in Python
Last Updated on August 27, 2020
XGBoost can be used to create some of the most performant models for tabular data using the gradient boosting algorithm.
Once trained, it is often a good practice to save your model to file for later use in making predictions new test and validation datasets and entirely new data.
In this post you will discover how to save your XGBoost models to file using the standard Python pickle API.
After completing this tutorial, you will know:
- How to save and later load your trained XGBoost model using pickle.
- How to save and later load your trained XGBoost model using joblib.
Kick-start your project with my new book XGBoost With Python, including step-by-step tutorials and the Python source code files for all examples.
Let’s get started.
- Update Jan/2017: Updated to reflect changes in scikit-learn API version 0.18.1.
- Update Mar/2018: Added alternate link to download the dataset as the original appears to have been taken down.
- Update Oct/2019: Updated to use Joblib API directly.