1.0 - 8.00 - KMeansPlot Example - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
Language
English (United States)

This example uses the table of cluster centroids output by a KMeans function example.

Input

  • input1: computers_test1

    The test data in this table is personal computer attributes—price, speed, hard disk size, RAM, and screen size. The table has over 1000 rows. If a row contains a null value, KMeansPlot assigns the cluster ID -1 to that row.

  • input2: kmeanssample_centroid, the table of cluster centroids output by KMeans Example 2: NumClusters, UnpackColumns ('true')
computers_test1
id price speed hd ram screen
10 2575 50 210 4 15
11 2195 33 170 8 15
15 2699 50 212 8 14
29 3095 33 340 16 14
30 3244 66 245 8 14
38 3795 66 500 8 14
45 3495 50 340 16 14
46 2695 33 245 8 14
48 1749 25 120 4 14
51 2499 33 170 4 14
52 2395 33 130 4 14
59 2945 66 210 8 17
65 2195 66 85 2 14
66 1495 25 170 4 14
70 3095 66 245 8 14
86 1999 33 120 8 14
91 2975 50 210 4 17
92 2145 66 130 4 14
93 2420 33 170 8 15
94 2505 50 210 8 14
104 2999 66 330 4 15
... ... ... ... ... ...

SQL Call

SELECT * FROM KMeansPlot (
  ON computers_test1 AS input1 PARTITION BY ANY
  ON kmeanssample_centroid AS input2 DIMENSION
) AS dt;

Output

id clusterid price speed hd ram screen
10 2 2575 50 210 4 15
11 4 2195 33 170 8 15
15 2 2699 50 212 8 14
29 6 3095 33 340 16 14
30 6 3244 66 245 8 14
38 1 3795 66 500 8 14
45 1 3495 50 340 16 14
46 2 2695 33 245 8 14
48 0 1749 25 120 4 14
51 2 2499 33 170 4 14
52 2 2395 33 130 4 14
59 6 2945 66 210 8 17
65 4 2195 66 85 2 14
66 0 1495 25 170 4 14
70 6 3095 66 245 8 14
86 4 1999 33 120 8 14
91 6 2975 50 210 4 17
92 4 2145 66 130 4 14
93 2 2420 33 170 8 15
94 2 2505 50 210 8 14
104 6 2999 66 330 4 15
... ... ... ... ... ... ...