Single model prediction | teradataml open-source machine learning functions - Single 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

To get predicted values, predict function should be called on the trained Booster object.

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

The following examples show how other supported functions can be accessed through Booster object.

model_to_string

>>> str_opt = opt_tr_s.model_to_string(-1)
>>> print(str_opt)
tree
version=v3
num_class=1
num_tree_per_iteration=1
label_index=0
max_feature_idx=3
objective=regression
...
...
[gpu_use_dp: 0]
[num_gpu: 1]

end of parameters

pandas_categorical:[]
# End of model string output.

model_from_string

>>> opt2 = opt_tr_s.model_from_string(str_opt)
>>> opt2
Finished loading model, total used 30 iterations
<lightgbm.basic.Booster object at 0x7f5553d235b0>