diff --git a/doc/source/xgboost-ray.rst b/doc/source/xgboost-ray.rst index 9a9623cf9..bc6c583fc 100644 --- a/doc/source/xgboost-ray.rst +++ b/doc/source/xgboost-ray.rst @@ -151,6 +151,8 @@ Package Reference Training/Validation ~~~~~~~~~~~~~~~~~~~ +.. autoclass:: ray.util.xgboost.RayParams + .. autofunction:: ray.util.xgboost.train .. autofunction:: ray.util.xgboost.predict diff --git a/python/ray/util/xgboost/__init__.py b/python/ray/util/xgboost/__init__.py index 52c953799..dac94f769 100644 --- a/python/ray/util/xgboost/__init__.py +++ b/python/ray/util/xgboost/__init__.py @@ -4,13 +4,15 @@ logger = logging.getLogger(__name__) train = None predict = None +RayParams = None RayDMatrix = None +RayFileType = None try: - from xgboost_ray import train, predict, RayDMatrix, RayFileType + from xgboost_ray import train, predict, RayParams, RayDMatrix, RayFileType except ImportError: logger.info( "xgboost_ray is not installed. Please run " "`pip install git+https://github.com/ray-project/xgboost_ray`.") -__all__ = ["train", "predict", "RayDMatrix", "RayFileType"] +__all__ = ["train", "predict", "RayParams", "RayDMatrix", "RayFileType"] diff --git a/python/ray/util/xgboost/simple_example.py b/python/ray/util/xgboost/simple_example.py index 4c29bf6a6..f48accfe6 100644 --- a/python/ray/util/xgboost/simple_example.py +++ b/python/ray/util/xgboost/simple_example.py @@ -1,7 +1,7 @@ from sklearn import datasets from sklearn.model_selection import train_test_split -from ray.util.xgboost import RayDMatrix, train +from ray.util.xgboost import RayDMatrix, RayParams, train # __xgboost_begin__ @@ -31,8 +31,7 @@ def main(): train_set, evals=[(test_set, "eval")], evals_result=evals_result, - max_actor_restarts=1, - checkpoint_path="/tmp/checkpoint/", + ray_params=RayParams(max_actor_restarts=1), verbose_eval=False) bst.save_model("simple.xgb") diff --git a/python/ray/util/xgboost/simple_tune.py b/python/ray/util/xgboost/simple_tune.py index ddb8769bc..2e10d30eb 100644 --- a/python/ray/util/xgboost/simple_tune.py +++ b/python/ray/util/xgboost/simple_tune.py @@ -1,7 +1,7 @@ from sklearn import datasets from sklearn.model_selection import train_test_split -from ray.util.xgboost import RayDMatrix, train +from ray.util.xgboost import RayDMatrix, RayParams, train # __train_begin__ num_cpus_per_actor = 1 @@ -25,8 +25,8 @@ def train_model(config): evals=[(test_set, "eval")], evals_result=evals_result, verbose_eval=False, - num_actors=num_actors, - cpus_per_actor=num_cpus_per_actor) + ray_params=RayParams( + num_actors=num_actors, cpus_per_actor=num_cpus_per_actor)) bst.save_model("model.xgb")