Update document for model dump. (#5818)

* Clarify the relationship between dump and save.
* Mention the schema.
This commit is contained in:
Jiaming Yuan
2020-06-22 14:33:54 +08:00
committed by GitHub
parent 26143ad0b1
commit 8104f10328
2 changed files with 38 additions and 30 deletions

View File

@@ -1444,8 +1444,11 @@ class Booster(object):
The model is saved in an XGBoost internal format which is universal
among the various XGBoost interfaces. Auxiliary attributes of the
Python Booster object (such as feature_names) will not be saved. To
preserve all attributes, pickle the Booster object.
Python Booster object (such as feature_names) will not be saved. See:
https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html
for more info.
Parameters
----------
@@ -1460,7 +1463,7 @@ class Booster(object):
raise TypeError("fname must be a string or os_PathLike")
def save_raw(self):
"""Save the model to a in memory buffer representation
"""Save the model to a in memory buffer representation instead of file.
Returns
-------
@@ -1479,8 +1482,11 @@ class Booster(object):
The model is loaded from an XGBoost format which is universal among the
various XGBoost interfaces. Auxiliary attributes of the Python Booster
object (such as feature_names) will not be loaded. To preserve all
attributes, pickle the Booster object.
object (such as feature_names) will not be loaded. See:
https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html
for more info.
Parameters
----------
@@ -1503,7 +1509,9 @@ class Booster(object):
raise TypeError('Unknown file type: ', fname)
def dump_model(self, fout, fmap='', with_stats=False, dump_format="text"):
"""Dump model into a text or JSON file.
"""Dump model into a text or JSON file. Unlike `save_model`, the
output format is primarily used for visualization or interpretation,
hence it's more human readable but cannot be loaded back to XGBoost.
Parameters
----------
@@ -1537,7 +1545,9 @@ class Booster(object):
fout.close()
def get_dump(self, fmap='', with_stats=False, dump_format="text"):
"""Returns the model dump as a list of strings.
"""Returns the model dump as a list of strings. Unlike `save_model`, the
output format is primarily used for visualization or interpretation,
hence it's more human readable but cannot be loaded back to XGBoost.
Parameters
----------
@@ -1547,6 +1557,7 @@ class Booster(object):
Controls whether the split statistics are output.
dump_format : string, optional
Format of model dump. Can be 'text', 'json' or 'dot'.
"""
fmap = os_fspath(fmap)
length = c_bst_ulong()