diff --git a/doc/jvm/xgboost4j_spark_tutorial.rst b/doc/jvm/xgboost4j_spark_tutorial.rst index dbfc6d765..c8fd951ed 100644 --- a/doc/jvm/xgboost4j_spark_tutorial.rst +++ b/doc/jvm/xgboost4j_spark_tutorial.rst @@ -345,6 +345,16 @@ and then loading the model in another session: val xgbClassificationModel2 = XGBoostClassificationModel.load(xgbClassificationModelPath) xgbClassificationModel2.transform(xgbInput) +.. note:: + + Besides dumping the model to raw format, users are able to dump the model to be json or ubj format from ``version 2.0.0+``. + + .. code-block:: scala + + val xgbClassificationModelPath = "/tmp/xgbClassificationModel" + xgbClassificationModel.write.overwrite().option("format", "json").save(xgbClassificationModelPath) + + With regards to ML pipeline save and load, please refer the next section. Interact with Other Bindings of XGBoost diff --git a/doc/tutorials/saving_model.rst b/doc/tutorials/saving_model.rst index 87e54054c..3ec329968 100644 --- a/doc/tutorials/saving_model.rst +++ b/doc/tutorials/saving_model.rst @@ -44,6 +44,7 @@ with normal model IO operation. Currently, memory snapshot is used in the follow * Python package: when the ``Booster`` object is pickled with the built-in ``pickle`` module. * R package: when the ``xgb.Booster`` object is persisted with the built-in functions ``saveRDS`` or ``save``. +* JVM packages: when the ``Booster`` object is serialized with the built-in functions ``saveModel``. Other language bindings are still working in progress. @@ -68,6 +69,12 @@ a filename with ``.json`` or ``.ubj`` as file extension, the latter is the exten xgb.save(bst, 'model_file_name.json') +.. code-block:: Scala + :caption: Scala + + val format = "json" // or val format = "ubj" + model.write.option("format", format).save("model_directory_path") + .. note:: Only load models from JSON files that were produced by XGBoost. Attempting to load