LightGBM
Deploy a model built with the LightGBM framework.
LightGBM is a gradient boosting framework. Baseten supports deploying LightGBM models out of the box.
All you need to do first is install the Baseten client and create an API key.
Baseten officially supports lightgbm version 3.3.2 or higher. Especially if you're using an online notebook environment like Google Colab or a bundle of packages like Anaconda, ensure that the version you are using is supported. If it's not, use the --upgrade flag and pip will install the most recent version.

Deploying a LightGBM model

Deploying a LightGBM model is as simple as:
import baseten
baseten_model = baseten.deploy(
lightgbm_model,
model_name='My LightGBM model',
)
If you have already saved your model, just load it back into memory, test it to ensure it works, and deploy as in the above.

Example deployment

This code sample deploys a LightGBM model.
import baseten
import lightgbm as lgb
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
def create_data():
X, y = make_classification(n_samples=100,
n_informative=2,
n_classes=2,
n_features=6)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
train = lgb.Dataset(X_train, y_train)
test = lgb.Dataset(X_test, y_test)
return train, test
train, test = create_data()
params = {
'boosting_type': 'gbdt',
'objective': 'softmax',
'metric': 'multi_logloss',
'num_leaves': 31,
'num_classes': 2,
'learning_rate': 0.05,
'feature_fraction': 0.9,
'bagging_fraction': 0.8,
'bagging_freq': 5,
'verbose': 0
}
model = lgb.train(params=params, train_set=train, valid_sets=test)
baseten.login("*** INSERT API KEY ***") # https://docs.baseten.co/settings/api-keys
baseten_model = baseten.deploy(
model,
model_name='lgb model',
)