KMeans Example 4: CentroidsTable, ClusteredOutput - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.00
1.0
Published
May 2019
Language
English (United States)
Last Update
2019-11-22
dita:mapPath
blj1506016597986.ditamap
dita:ditavalPath
blj1506016597986.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantage™

SQL Call

SELECT * FROM KMeans (
  ON computers_train1 AS InputTable
  ON kmeanssample_centroid AS CentroidsTable
  OUT TABLE OutputTable (kmeanssample_output)
  OUT TABLE ClusteredOutput (kmeanssample_clusteredoutput)
) AS dt;

Output

Results Message Table
clusterid price speed hd ram screen size withinss
0 2960.01480263158 60.1644736842105 433.212171052632 12.0592105263158 14.8569078947368 608 2.492322446875E7
1 2497.71428571429 54.0223880597015 451.369936034115 9.97441364605544 14.7430703624733 938 3.96035350565033E7
2 2835.60828025478 62.9140127388535 1065.35031847134 21.6050955414013 15.1210191082803 314 3.29830353949041E7
3 1448.66487213997 40.8761776581427 266.581426648721 4.14535666218035 14.2395693135935 743 2.56143746433377E7
4 1786.32992327366 42.5319693094629 216.745524296675 4.11253196930946 14.3388746803069 782 1.47750572352934E7
5 3765.46783625731 65.7953216374269 603.818713450292 12.9824561403509 15.2222222222222 171 3.52858142923985E7
6 2137.35222222222 49.0888888888889 285.062222222222 5.79555555555556 14.4355555555556 900 2.41126403944445E7
7 1933.7481884058 63.2554347826087 643.766304347826 8.55072463768116 14.786231884058 552 3.6313263190217E7
  Converged: False    
  NumberofIterations: 10    
  Numberofclusters: 8    
  Successfully created Output table    
  Successfully created Clustered Output table    
  Total_WithinSS: 2.3361094467584848E8    
  Between_SS: 1.8049765478491178E9    

This query returns the following table:

SELECT * FROM kmeanssample_output ORDER BY clusterid;
kmeanssample_output
clusterid price speed hd ram screen size withinss
0 1510.08542713568 39.9145728643216 239.678391959799 3.99396984924623 14.2241206030151 995 37808731.5477371
1 3804.3660130719 63.5294117647059 555.934640522876 11.8954248366013 15.2679738562092 153 29924035.307189
2 2450.51741803279 53.5676229508197 375.327868852459 8.31147540983607 14.6270491803279 976 33481207.880125
3 2347.81981981982 64.7027027027027 880.27027027027 14.9189189189189 15.1681681681682 333 19978017.8258257
4 2008.36318897638 44.7716535433071 230.882874015748 4.79330708661417 14.3818897637795 1016 29263951.4901571
5 3003.32231404959 60.8595041322314 1077.52066115702 23.0743801652893 14.9752066115702 242 19866556.9917355
6 2941.27786259542 60.0106870229008 445.116030534351 12.2320610687023 14.8595419847328 655 29342001.3404598
7 1863.89498432602 59.8761755485893 523.753918495298 7.18495297805643 14.6943573667712 638 24142481.1222563

This query returns the following table:

SELECT * FROM kmeanssample_clusteredoutput ORDER BY id;
kmeanssample_clusteredoutput
id clusterid
1 0
2 4
3 0
4 4
5 6
6 1
7 0
8 4
9 4
12 2
13 4
14 2
16 4
17 0
18 2
19 4
20 1
... ...