Multi model prediction | teradataml open-source machine learning functions - Multi model prediction - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2025-01-23
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

For prediction in muti model case, partition_columns argument may or may not be provided. If this argument is not provided, the partition columns and values are taken from training.

>>> opt_pred_m = opt_tr_m.predict(data=df_x_classif, label=df_y_classif, num_iteration=20)
>>> opt_pred_m.head(3)
	partition_column_1	partition_column_2	             col1	             col2	              col3	             col4	label	 booster_predict_1
                     1                  10  0.191240730419773	 1.97100133015377	-0.298530178457708	0.890194110648821	    1	0.9609170779776948
                     0                  10  -1.16999138897268	0.354732459083604	-0.193563184945544	-0.35802804454994	    1	0.9358935125840876
                     1                  11   1.61885814289279	0.530672471352164	 0.101599080962697	0.914093399898154	    0	0.4503489139975592

Booster Wrapper object can be instantiated by passing arguments to the class as follows:

Passing model_file argument

The existing model needs to be saved to a file.

>>> opt_tr_s.save_model("model_file_single_partition")
<lightgbm.basic.Booster object at 0x7f5553bbe250>

Instantiate Booster Wrapper object through model_file argument

>>> direct_obj = td_lightgbm.Booster(model_file="model_file_single_partition")
>>> direct_obj
<lightgbm.basic.Booster object at 0x7f5553c28580>

Use model_str argument if model is already present as string

>>> direct_obj1 = td_lightgbm.Booster(model_str = str_opt)
>>> direct_obj1
<lightgbm.basic.Booster object at 0x7f5553b6c220>