You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/deployments/exporting.md
+13-3
Original file line number
Diff line number
Diff line change
@@ -136,14 +136,24 @@ with open("model.onnx", "wb") as f:
136
136
137
137
### `pickle`
138
138
139
-
XGBoost models are typically exported using `pickle`. Here is [XGBoost's documentation](https://machinelearningmastery.com/save-gradient-boosting-models-xgboost-python/).
139
+
XGBoost models can be exported using `pickle`.
140
140
141
-
The code to export a model would look like this:
141
+
For example:
142
142
143
143
```python
144
144
pickle.dump(model, open("model.pkl", "wb"))
145
145
```
146
146
147
+
### `Booster.save_model()`
148
+
149
+
XGBoost `Booster` models can also be exported using [`xgboost.Booster.save_model()`](https://xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost.Booster.save_model). Auxiliary attributes of the Booster object (e.g. feature_names) will not be saved. To preserve all attributes, you can use `pickle` (see above).
150
+
151
+
For example:
152
+
153
+
```python
154
+
model.save_model("model.bin")
155
+
```
156
+
147
157
### ONNX
148
158
149
159
It is also possible to export an XGBoost model to the ONNX format using [onnxmltools](https://github.com/onnx/onnxmltools).
@@ -155,7 +165,7 @@ It is also possible to export an XGBoost model to the ONNX format using [onnxmlt
155
165
from onnxmltools.convert import convert_xgboost
156
166
from onnxconverter_common.data_types import FloatTensorType
0 commit comments