Example: Deploy and Load Single Model | teradataml OpenSourceML - Example: Deploy and Load Single Model - 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
  1. Train the model.
    1. Import the module.
      >>> from teradataml import td_sklearn as osml
    2. Create an object.
      >>> kmeans1 = osml.KMeans(n_clusters=4, algorithm="elkan", init="random")
      >>> kmeans1.set_params(n_clusters=6, tol=0.1)
      >>> kmeans1.fit(X=df_train.select(feature_columns))
      KMeans(algorithm='elkan', init='random', n_clusters=6, tol=0.1)
  2. Deploy the model.
    >>> kmeans1.deploy(model_name="test_kmeans_no_partition", replace_if_exists=True)
    Model is deleted.
    Model is saved.
    KMeans(algorithm='elkan', init='random', n_clusters=6, tol=0.1)
  3. Load the model.
    >>> loaded1 = osml.load(model_name="test_kmeans_no_partition")
    >>> loaded1
    KMeans(algorithm='elkan', init='random', n_clusters=6, tol=0.1)
  4. Predict on loaded model.
    >>> loaded1.predict(df_train.select(feature_columns))
                  col1                 col2                 col3                 col4     kmeans_predict_1
      3.03238599297047     3.03481436440056    -2.82355004664948     1.92120455311016                    3
      1.01738017000636     1.33916140701086    -1.82497543774135    0.807901883197634                    3
      1.31804370433225    0.178246937722197     1.89230973992192    0.254523189858355                    1
    -0.651461127752867    -0.63774973705703    0.567676564082086    -0.40549830544753                    0
     -1.17935408605987    -0.06353714170578    -1.95557314394007    -0.17891371408631                    4
    -0.428384248092839    -0.23480968295742    -0.13137227859559    -0.17273019020336                    0
    -0.695735879594567    -1.07084898019651     1.67201893676997    -0.63139004513942                    5
     -1.23995029412835    -1.07952124763549    0.713159403625714    -0.70344346319249                    0
      2.48384809580349     2.37973754066001    -2.02266697958209     1.51968143653911                    3
      1.55458501178875     1.85365285731526    -2.26189922281813      1.1364775082343                    3