ray.train.lightgbm.LightGBMTrainer
ray.train.lightgbm.LightGBMTrainer#
- class ray.train.lightgbm.LightGBMTrainer(*args, **kwargs)[source]#
Bases:
ray.train.gbdt_trainer.GBDTTrainer
A Trainer for data parallel LightGBM training.
This Trainer runs the LightGBM training loop in a distributed manner using multiple Ray Actors.
If you would like to take advantage of LightGBM’s built-in handling for features with the categorical data type, consider using the
Categorizer
preprocessor to set the dtypes in the dataset.Note
LightGBMTrainer
does not modify or otherwise alter the working of the LightGBM distributed training algorithm. Ray only provides orchestration, data ingest and fault tolerance. For more information on LightGBM distributed training, refer to LightGBM documentation.Example
import ray from ray.train.lightgbm import LightGBMTrainer from ray.air.config import ScalingConfig train_dataset = ray.data.from_items( [{"x": x, "y": x + 1} for x in range(32)]) trainer = LightGBMTrainer( label_column="y", params={"objective": "regression"}, scaling_config=ScalingConfig(num_workers=3), datasets={"train": train_dataset} ) result = trainer.fit()
- Parameters
datasets – Ray Datasets to use for training and validation. Must include a “train” key denoting the training dataset. If a
preprocessor
is provided and has not already been fit, it will be fit on the training dataset. All datasets will be transformed by thepreprocessor
if one is provided. All non-training datasets will be used as separate validation sets, each reporting a separate metric.label_column – Name of the label column. A column with this name must be present in the training dataset.
params – LightGBM training parameters passed to
lightgbm.train()
. Refer to LightGBM documentation for a list of possible parameters.dmatrix_params – Dict of
dataset name:dict of kwargs
passed to respectivexgboost_ray.RayDMatrix
initializations, which in turn are passed tolightgbm.Dataset
objects created on each worker. For example, this can be used to add sample weights with theweights
parameter.scaling_config – Configuration for how to scale data parallel training.
run_config – Configuration for the execution of the training run.
preprocessor – A ray.data.Preprocessor to preprocess the provided datasets.
resume_from_checkpoint – A checkpoint to resume training from.
**train_kwargs – Additional kwargs passed to
lightgbm.train()
function.
PublicAPI (beta): This API is in beta and may change before becoming stable.