LightGBM¶
The Snowflake ML Model Registry supports models created using LightGBM (models derived from the scikit-learn API wrapper, e.g. lightgbm.LGBMClassifier or the native API, e.g. lightgbm.Booster).
The following additional options can be used in the options dictionary when you call log_model:
| Option | Description |
|---|---|
target_methods | A list of the names of the methods available on the model object. Models derived from the scikit-learn API (e.g. LGBMClassifier) have the following target methods by default, assuming the method exists: predict, predict_proba. Models derived from the native API (e.g. Booster) have the predict method by default. |
enable_explainability | Whether to enable explainability for the model using SHAP. Defaults to True. When enabled, an explain method will be available on the logged model. |
cuda_version | The version of the CUDA runtime to be used when deploying to a platform with GPU; defaults to 11.8. If manually set to None, the model cannot be deployed to a platform having a GPU. |
You must specify either the sample_input_data or signatures parameter when logging a LightGBM model so
that the registry knows the signatures of the target methods.
Examples¶
These examples assume reg is an instance of snowflake.ml.registry.Registry.
Scikit-Learn API (LGBMClassifier)¶
The following example demonstrates the key steps to train a LightGBM classifier using the scikit-learn API, log it to the Snowflake ML Model Registry, and use the registered model for inference and explainability. The workflow includes:
- Trains a LightGBM classifier on a sample dataset.
- Logs the model to the Snowflake ML Model Registry.
- Makes predictions and retrieves prediction probabilities.
- Gets SHAP values for the model’s predictions.
Native API (Booster)¶
The following example demonstrates the key steps to train a LightGBM model using the native Snowflake ML API, log it to the Snowflake ML Model Registry, and use the registered model for inference. The workflow does the following:
- Trains a LightGBM model on a sample dataset.
- Logs the model to the Snowflake ML Model Registry.
- Makes predictions.