ray.train.xgboost.XGBoostCheckpoint.from_model#

classmethod XGBoostCheckpoint.from_model(booster: xgboost.core.Booster, *, preprocessor: Optional[Preprocessor] = None) XGBoostCheckpoint[source]#

Create a Checkpoint that stores an XGBoost model.

Parameters
  • booster – The XGBoost model to store in the checkpoint.

  • preprocessor – A fitted preprocessor to be applied before inference.

Returns

An XGBoostCheckpoint containing the specified Estimator.

Examples

… testcode:

import numpy as np
import ray
from ray.train.xgboost import XGBoostCheckpoint
import xgboost

train_X = np.array([[1, 2], [3, 4]])
train_y = np.array([0, 1])

model = xgboost.XGBClassifier().fit(train_X, train_y)
checkpoint = XGBoostCheckpoint.from_model(model.get_booster())

You can use a XGBoostCheckpoint to create an XGBoostPredictor and preform inference.

… testcode:

from ray.train.xgboost import XGBoostPredictor
predictor = XGBoostPredictor.from_checkpoint(checkpoint)