Teradata Package for Python Function Reference on VantageCloud Lake - deploy - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.
Teradata® Package for Python Function Reference on VantageCloud Lake
- Deployment
- VantageCloud
- Edition
- Lake
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- ft:locale
- en-US
- ft:lastEdition
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Lake_2000
- Product Category
- Teradata Vantage
- teradataml.opensource.td_lightgbm.deploy = deploy(model_name, model, replace_if_exists=False)
- DESCRIPTION:
Deploys the model to Vantage.
PARAMETERS:
model_name:
Required Argument.
Specifies the unique name of the model to be deployed.
Types: str
model:
Required Argument.
Specifies the teradataml supported opensource model object that is to be deployed.
Currently supported models are:
- sklearn
- lightgbm
Types: object
replace_if_exists:
Optional Argument.
Specifies whether to replace the model if a model with the same name already
exists in Vantage. If this argument is set to False and a model with the same
name already exists, then the function raises an exception.
Default Value: False
Types: bool
RETURNS:
The opensource object wrapper.
RAISES:
TeradataMLException if model with "model_name" already exists and the argument
"replace_if_exists" is set to False.
EXAMPLES:
# Import required packages and create LGBMClassifier lightGBM object.
>>> from teradataml import td_lightgbm
>>> import lightgbm as lgb
>>> model = lgb.LGBMClassifier()
# Example 1: Deploy the LightGBM model to Vantage.
>>> lgb_model = td_lightgbm.deploy("lgb_model_ver_1", model)
Model is saved.
>>> lgb_model
LGBMClassifier()
# Example 2: Deploy the LightGBM model to Vantage with the name same as that of model that
# already existed in Vantage.
>>> lgb_model = td_lightgbm.deploy("lgb_model_ver_1", model, replace_if_exists=True)
Model is deleted.
Model is saved.
>>> lgb_model
LGBMClassifier()
# Example 3: Deploy LightGBM model trained locally using train() function to Vantage.
# Create Dataset object locally, assuming pdf_x and pdf_y are the feature and label pandas
# DataFrames.
>>> lgbm_data = lgb.Dataset(data=pdf_x, label=pdf_y, free_raw_data=False)
>>> lgbm_data
<lightgbm.basic.Dataset object at ....>
# Train the model using train() function.
>>> model = lgb.train(params={}, train_set=lgbm_data, num_boost_round=30, valid_sets=[lgbm_data])
[LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.000043 seconds.
You can set `force_row_wise=true` to remove the overhead.
And if memory is not enough, you can set `force_col_wise=true`.
[LightGBM] [Info] Total Bins 532
[LightGBM] [Info] Number of data points in the train set: 400, number of used features: 4
[1] valid_0's l2: 0.215811
[2] valid_0's l2: 0.188138
[3] valid_0's l2: 0.166146
...
...
[29] valid_0's l2: 0.042255
[30] valid_0's l2: 0.0416953
# Deploy the model to Vantage.
>>> lgb_model = td_lightgbm.deploy("lgb_model_ver_2", model)
>>> lgb_model
<lightgbm.basic.Booster object at ...>