1.1 - 8.10 - KMeans Example: InitialSeeds, ClusterAssignmentTable - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

Input

SQL Call

SELECT * FROM KMeans (
  ON computers_train1 AS InputTable
  OUT TABLE OutputTable (kmeanssample_output)
  OUT TABLE ClusterAssignmentTable (kmeanssample_clusteredoutput)
  USING
   
  InitialSeeds('2249_51_408_8_14', '2165_51_398_7_14.6', 
    '2182_51_404_7_14.6', '2204_55_372_7.19_14.6',
    '2419_44_222_6.6_14.3', '2394_44.3_277_7.3_14.5',
    ' 2326_43.6_301_7.11_14.3', '2288_44_325_7_14.4')
) AS dt;

Output

 clusterid mean                                                                                 size withinss         
 --------- ------------------------------------------------------------------------------------ ---- ---------------- 
 0         2249.0 51.0 408.0 8.0 14.0                                                           0    0.0             
 1         1566.83333333333 28.3333333333333 125.833333333333 3.83333333333333 14.0833333333333 12   218374.583333351
 2         2182.0 51.0 404.0 7.0 14.6                                                           0    0.0             
 3         1940.125 37.25 151.875 4.25 14.0625                                                  16   141346.4375     
 4         4026.42857142857 59.0 432.285714285714 9.14285714285714 14.2857142857143             7    324109.428571463
 5         3072.21428571429 52.6428571428571 271.071428571429 8.57142857142857 14.7142857142857 14   586706.785714269
 6         2568.3125 43.5 217.75 7.0 14.625                                                     16   252294.1875     
 7         2218.2 40.2666666666667 196.6 5.6 14.1333333333333                                   15   117724.266666621
 --------- ------------------------------------------------------------------------------------ ---- ----------------
           Converged : True                                                                                          
           Number of Iterations : 8                                                                                  
           Number of clusters : 8                                                                                    
           Successfully created Output table                                                                         
           Successfully created Clustered Output table                                                               
           Total_WithinSS : 1640555.689285704                                                                        
           Between_SS : 3.790632606071441E7
SELECT * FROM kmeanssample_output;
 clusterid mean                                                                                 size withinss         
 --------- ------------------------------------------------------------------------------------ ---- ---------------- 
         1 1566.83333333333 28.3333333333333 125.833333333333 3.83333333333333 14.0833333333333   12 218374.583333351
         3 1940.125 37.25 151.875 4.25 14.0625                                                    16      141346.4375
         5 3072.21428571429 52.6428571428571 271.071428571429 8.57142857142857 14.7142857142857   14 586706.785714269
         7 2218.2 40.2666666666667 196.6 5.6 14.1333333333333                                     15 117724.266666621
         0 2249.0 51.0 408.0 8.0 14.0                                                              0              0.0
         2 2182.0 51.0 404.0 7.0 14.6                                                              0              0.0
         4 4026.42857142857 59.0 432.285714285714 9.14285714285714 14.2857142857143                7 324109.428571463
         6 2568.3125 43.5 217.75 7.0 14.625                                                       16      252294.1875
SELECT * FROM kmeanssample_clusteredoutput;
 id  clusterid 
 --- --------- 
  28         4
  53         5
  42         4
  23         5
  20         4
  17         1
  99         6
  68         1
  85         6
  81         5
  34         6
  95         5
  33         6
  78         5
  40         6
  26         1
  22         6
  24         5
  12         6
   1         1
  43         6
  58         5
   6         4
  75         5
  71         4
  90         5
  61         4
  97         3
  25         4
  14         7
  36         6
  69         7
  84         6
  32         3
  49         6
  87         7
  63         6
  16         7
  72         6
  57         3
  39         6
  62         3
  82         6
  77         3
  79         6
  54         7
  27         3
   4         3
  60         3
  98         3
   8         3
  74         5
 100         1
  21         1
  89         1
  83         5
  80         1
   7         1
  76         5
   5         5
   3         1
  41         5
  96         1
  73         1
  19         7
  47         7
  31         3
  13         3
   9         7
  64         7
  88         3
  55         7
  37         7
  35         3
  50         3
  67         7
  44         7
  18         7
  56         7
   2         3

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.