ray.train.xgboost.XGBoostCheckpoint.from_model
ray.train.xgboost.XGBoostCheckpoint.from_model#
- classmethod XGBoostCheckpoint.from_model(booster: xgboost.core.Booster, *, preprocessor: Optional[Preprocessor] = None) XGBoostCheckpoint[source]#
Create a
Checkpointthat 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
XGBoostCheckpointcontaining the specifiedEstimator.
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
XGBoostCheckpointto create anXGBoostPredictorand preform inference.… testcode:
from ray.train.xgboost import XGBoostPredictor predictor = XGBoostPredictor.from_checkpoint(checkpoint)