πTrainer & Predictor
Overview
With Ray Remote Task and Jobs, we can easily access the distributed computing capabilities of Ray framework to boost our workloads. When performing model training, Ray native trainers are optimized even further. Thus, the Fiat Copilot trainer module provides utilities to help users define Ray Native trainers.
XGBoost Utils
from ray.air import Result
from ray.data import Preprocessor
def define_xgb_trainer_and_fit(
dataset: dict, # {"train": ..., "test": ...}
label_col: str,
scaling_conf: dict,
boost_round: int,
training_params: dict,
preprocess_pipeline: Preprocessor,
) -> ResultYou can use the util function define_xgb_trainer_and_fit to get a Ray trained Result object. It has the following attributes -
# metrics dict
result.metrics
# metrics Pandas dataframe
result.metrics_dataframe
# Ray AIR checkpoint
result.checkpointYou can also directly convert a pre-trained Booster model into XGBoostCheckpoint -
With checkpoints, you can easily define your Predictor object -
Here is a complete example -
PyTorch Lightning Utils
PyTorch is one of the most popular Deep Learning framework in AI field. Fiat Copilot also provides some utilities of Torch Lightning module.
You can first define your lightning config by calling the build_lightning_config function -
Then, you can define your Ray Lightning Trainer by invoking the form_lightning_trainer function -
You can also easily define your Hyperparameter Tuner with the form_lightning_tuner function. With SyncConfig, we can syncing with external storage to persist our tuning experiments' results -
Here is a complete example -
Last updated