- Train the model.
- Import the module.
>>> from teradataml import td_sklearn as osml
- 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)
- Import the module.
- 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)
- Load the model.
>>> loaded1 = osml.load(model_name="test_kmeans_no_partition")
>>> loaded1
KMeans(algorithm='elkan', init='random', n_clusters=6, tol=0.1)
- 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