KMeans Example: NumClusters, UnpackColumns ('true') | Teradata Vantage - KMeans Example: NumClusters, UnpackColumns ('true') - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

Input

SQL Call

SELECT * FROM KMeans (
  ON computers_train1 AS InputTable
  OUT TABLE OutputTable (kmeanssample_centroid2)
  USING
  UnpackColumns ('true')
  NumClusters (8)
  StopThreshold (0.05)
  MaxIterNum (10)
) AS dt;

Output

 clusterid mean                                                                                 size withinss         
 --------- ------------------------------------------------------------------------------------ ---- ---------------- 
 0         1435.6 26.6 107.0 3.2 14.0                                                           5    40551.1999999993
 1         2477.82352941176 44.3529411764706 217.0 7.05882352941176 14.4117647058824            17   266923.411764711
 2         2985.0625 51.1875 253.4375 8.0 14.875                                                16   628673.0625     
 3         3959.375 57.875 419.5 9.0 14.25                                                      8    585122.25       
 4         1660.57142857143 29.5714285714286 139.285714285714 4.28571428571429 14.1428571428571 7    27135.1428571418
 5         1808.5 31.0 138.75 4.5 14.25                                                         4    7173.5          
 6         1984.0 39.3333333333333 156.25 4.16666666666667 14.0                                 12   40644.5833333135
 7         2182.09090909091 37.6363636363636 195.818181818182 5.45454545454545 14.0909090909091 11   54416.7272727191
 --------- ------------------------------------------------------------------------------------ ---- ----------------
           Converged : False                                                                                         
           Number of Iterations : 10                                                                                 
           Number of clusters : 8                                                                                    
           Successfully created Output table                                                                         
           Total_WithinSS : 1650639.8777278848                                                                       
           Between_SS : 3.789624187227207E7
SELECT * FROM kmeanssample_centroid2;
 clusterid price            speed            hd               ram              screen           size withinss         
 --------- ---------------- ---------------- ---------------- ---------------- ---------------- ---- ---------------- 
         1 2477.82352941176 44.3529411764706            217.0 7.05882352941176 14.4117647058824   17 266923.411764711
         3         3959.375           57.875            419.5              9.0            14.25    8        585122.25
         5           1808.5             31.0           138.75              4.5            14.25    4           7173.5
         7 2182.09090909091 37.6363636363636 195.818181818182 5.45454545454545 14.0909090909091   11 54416.7272727191
         0           1435.6             26.6            107.0              3.2             14.0    5 40551.1999999993
         2        2985.0625          51.1875         253.4375              8.0           14.875   16      628673.0625
         4 1660.57142857143 29.5714285714286 139.285714285714 4.28571428571429 14.1428571428571    7 27135.1428571418
         6           1984.0 39.3333333333333           156.25 4.16666666666667             14.0   12 40644.5833333135

Download a zip file of all examples and a SQL script file that creates their input tables.