ray.train.lightgbm.LightGBMCheckpoint
ray.train.lightgbm.LightGBMCheckpoint#
- class ray.train.lightgbm.LightGBMCheckpoint(local_path: Optional[Union[str, os.PathLike]] = None, data_dict: Optional[dict] = None, uri: Optional[str] = None)[source]#
Bases:
ray.air.checkpoint.Checkpoint
A
Checkpoint
with LightGBM-specific functionality.Create this from a generic
Checkpoint
by callingLightGBMCheckpoint.from_checkpoint(ckpt)
.PublicAPI (beta): This API is in beta and may change before becoming stable.
- classmethod from_model(booster: lightgbm.basic.Booster, *, preprocessor: Optional[Preprocessor] = None) LightGBMCheckpoint [source]#
Create a
Checkpoint
that stores a LightGBM model.- Parameters
booster – The LightGBM model to store in the checkpoint.
preprocessor – A fitted preprocessor to be applied before inference.
- Returns
An
LightGBMCheckpoint
containing the specifiedEstimator
.
Examples
>>> import lightgbm >>> import numpy as np >>> from ray.train.lightgbm import LightGBMCheckpoint >>> >>> train_X = np.array([[1, 2], [3, 4]]) >>> train_y = np.array([0, 1]) >>> >>> model = lightgbm.LGBMClassifier().fit(train_X, train_y) >>> checkpoint = LightGBMCheckpoint.from_model(model.booster_)
You can use a
LightGBMCheckpoint
to create anLightGBMPredictor
and preform inference.>>> from ray.train.lightgbm import LightGBMPredictor >>> >>> predictor = LightGBMPredictor.from_checkpoint(checkpoint)