Teradata Package for Python Function Reference | 20.00 - An Interface Object for LightGBM - 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 - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
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_Enterprise_2000
lifecycle
latest
Product Category
Teradata Vantage

 
teradataml.opensource.td_lightgbm = <teradataml.opensource._class.Lightgbm object>
    DESCRIPTION:
    Interface object to access exposed classes and functions of lightgbm
    opensource package. All the classes and functions can be run and attributes
    can be accessed using the object created by "td_lightgbm" interface object.
    Refer Teradata Python Package User Guide for more information about OpenML
    and exposed interface objects.
 
PARAMETERS:
    None
 
RETURNS:
    None
 
EXAMPLES:
    # Load example data.
    >>> load_example_data("openml", ["test_classification"])
    >>> df = DataFrame("test_classification")
    >>> df.head(3)
                   col2      col3      col4  label
    col1
    -2.560430  0.402232 -1.100742 -2.959588      0
    -3.587546  0.291819 -1.850169 -4.331055      0
    -3.697436  1.576888 -0.461220 -3.598652      0
 
    # Get the feature and label data.
    >>> df_x = df.select(df.columns[:-1])
    >>> df_y = df.select(df.columns[-1])
 
    >>> from teradataml import td_lightgbm
 
    # Example 1: Train the model using train() function.
    # Create lightgbm Dataset object.
    >>> lgbm_data = td_lightgbm.Dataset(data=df_x, label=df_y, free_raw_data=False)
    >>> lgbm_data
    <lightgbm.basic.Dataset object at ...>
 
    # Train the model.
    >>> model = td_lightgbm.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
    >>> model
    <lightgbm.basic.Booster object at ...>
 
    # Example 2: Train the model using LGBMClassifier sklearn object.
    # Create lightgbm sklearn object.
    >>> lgbm_cl = td_lightgbm.LGBMClassifier()
    >>> lgbm_cl
    LGBMClassifier()
 
    # Fit/train the model using fit() function.
    >>> lgbm_cl.fit(df_x, df_y)
    LGBMClassifier()
 
    # Perform prediction.
    >>> lgbm_cl.predict(df_x).head(3)
           col1      col2      col3      col4  lgbmclassifier_predict_1
    0  1.105026 -1.949894 -1.537164  0.073171                         1
    1  1.878349  0.577289  1.795746  2.762539                         1
    2 -1.130582 -0.020296 -0.710234 -1.440991                         0
 
    # Access attributes.
    >>> lgbm_cl.feature_importances_
    array([ 0, 20, 10, 10])