1.1 - 8.10 - KModesPredict Example - 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 KModesPredict (
  ON kmodes_clusters AS model dimension ORDER BY distance_metric
  ON kmodes_input AS InputTable PARTITION BY ANY
  USING
  accumulate ('model')
) AS dt ;

Output

Each InputTable row is assigned one of the three clusters.

 cluster_id mpg          disp         hp           drat         wt           qsec         cyl vs am        gear carb model               
 ---------- ------------ ------------ ------------ ------------ ------------ ------------ --- -- --------- ---- ---- ------------------- 
 2           0.449543447 -0.990182091 -0.783040459  0.473999587 -0.917004624  0.426006817 4   v  manual    4    1    datsun 710         
 2           1.710546517  -1.25079481 -1.381031775  2.493904115 -1.637526508  0.375641479 4   v  manual    4    2    honda civic        
 1           0.150884825 -0.570619819  -0.53509284  0.567513685 -0.610399567 -0.777165145 6   s  manual    4    4    mazda rx4          
 1           -0.71190675  0.970464681  1.711020886  1.166003916 -0.048290296 -1.874010283 8   s  manual    5    4    ford pantera l     
 2           0.449543447 -0.725535119 -0.753870151  0.604919325 -0.068730634  2.826754593 4   v  automatic 4    2    merc 230           
 2          -0.380063837 -0.509299179 -0.345485837  0.604919325  0.227654255  0.588295128 6   v  automatic 4    4    merc 280c          
 2          -0.147773797 -0.509299179 -0.345485837  0.604919325  0.227654255  0.252526208 6   v  automatic 4    4    merc 280           
 0          -0.761683187  0.704204008  0.048313323 -1.564607761  0.309415603  -0.54772305 8   s  automatic 3    2    dodge challenger   
 2           1.196190002 -1.224168743 -1.176839619   0.90416444 -1.310481114  0.588295128 4   v  manual    4    1    fiat x1-9          
 0          -1.126710392  0.962396176  1.433902959   0.24956575  0.636460997 -1.364760755 8   s  automatic 3    4    camaro z28         
 2           0.715017777 -0.677930938 -1.235180235  0.174754472 -0.027849959  1.203871481 4   v  automatic 4    2    merc 240d          
 0           0.217253407  0.220093694  -0.53509284  -0.96611753 -0.002299538  0.890487156 6   v  automatic 3    1    hornet 4 drive     
 0          -0.811459624  0.591244935  0.048313323 -0.835197792   0.22254417 -0.307088658 8   s  automatic 3    2    amc javelin        
 1          -0.064813069 -0.691647397  0.412942174  0.043834734 -0.457097039 -1.314395417 6   s  manual    5    6    ferrari dino       
 0          -0.811459624  0.363713088  0.485867945  -0.98482035  0.575139986  0.084641749 8   s  automatic 3    3    merc 450slc        
 2           0.217253407 -0.885291523 -0.549677994  0.960272899  -0.44687687  0.420410668 4   v  manual    4    2    volvo 142e         
 0          -0.894420352  1.688561647  1.215125648 -0.685575235  2.174596366 -0.239934874 8   s  automatic 3    4    chrysler imperial  
 2           1.710546517 -1.094265808 -0.491337378  0.324377029 -1.741772228 -0.530934604 4   v  manual    5    2    lotus europa       
 1           0.150884825 -0.570619819  -0.53509284  0.567513685 -0.349785269  -0.46378082 6   s  manual    4    4    mazda rx4 wag      
 0            -0.3302874 -0.046166978  -0.60801861 -1.564607761  0.248094592  1.326986752 6   v  automatic 3    1    valiant            
 0          -0.230734526  1.043081228  0.412942174 -0.835197792  0.227654255  -0.46378082 8   s  automatic 3    2    hornet sportabout  
 1          -0.844643915  0.567039419  2.746566825 -0.105787824  0.360516446 -1.818048797 8   s  manual    5    8    maserati bora      
 0          -0.463024565  0.363713088  0.485867945  -0.98482035  0.524039143 -0.139204198 8   s  automatic 3    3    merc 450sl         
 2           0.980492108 -0.890939476 -0.812210767   1.55876313 -1.100967659 -0.642857578 4   s  manual    5    2    porsche 914-2      
 0          -0.960788935  1.043081228  1.433902959 -0.722980874  0.360516446 -1.124126363 8   s  automatic 3    4    duster 360         
 0          -1.607882616  1.849931752  0.996348337 -1.115740088  2.255335698 -0.016088927 8   s  automatic 3    4    lincoln continental
 2           0.233845553 -0.892553178 -0.724699843  0.193457291  -0.76881218   1.20946763 4   v  automatic 3    1    toyota corona      
 2           2.291271616 -1.287909934 -1.191424773  1.166003916   -1.4126828  1.147909994 4   v  manual    4    1    toyota corolla     
 0          -0.147773797  1.365821438  0.412942174  -0.96611753  0.641571082 -0.446992374 8   s  automatic 3    2    pontiac firebird   
 2           2.042389431 -1.226589294 -1.176839619   0.90416444 -1.039646647  0.907275602 4   v  manual    4    1    fiat 128           
 0          -1.607882616  1.946753815  0.850496796 -1.246659826  2.077504765  0.073449451 8   s  automatic 3    4    cadillac fleetwood 
 0          -0.612353876  0.363713088  0.485867945  -0.98482035  0.871524874 -0.251127171 8   s  automatic 3    3    merc 450se

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