1.1 - 8.10 - GMMPredict 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)

The GMMPredict function applies the model created by the GMM function to the test input to cluster the test data.

Input

InputTable: gmm_iris_test
id sepal_length sepal_width petal_length petal_width
5 5 3.6 1.4 0.2
10 4.9 3.1 1.5 0.1
15 5.8 4 1.2 0.2
20 5.1 3.8 1.5 0.3
25 4.8 3.4 1.9 0.2
30 4.7 3.2 1.6 0.2
35 4.9 3.1 1.5 0.2
40 5.1 3.4 1.5 0.2
45 5.1 3.8 1.9 0.4
50 5 3.3 1.4 0.2
55 6.5 2.8 4.6 1.5
60 5.2 2.7 3.9 1.4
65 5.6 2.9 3.6 1.3
70 5.6 2.5 3.9 1.1
75 6.4 2.9 4.3 1.3
80 5.7 2.6 3.5 1
85 5.4 3 4.5 1.5
90 5.5 2.5 4 1.3
95 5.6 2.7 4.2 1.3
100 5.7 2.8 4.1 1.3
105 6.5 3 5.8 2.2
110 7.2 3.6 6.1 2.5
115 5.8 2.8 5.1 2.4
120 6 2.2 5 1.5
125 6.7 3.3 5.7 2.1
130 7.2 3 5.8 1.6
135 6.1 2.6 5.6 1.4
140 6.9 3.1 5.4 2.1
145 6.7 3.3 5.7 2.5
150 5.9 3 5.1 1.8

SQL Call

SELECT * FROM GMMPredict (
  ON gmm_output_ex1 AS Model DIMENSION
  ON gmm_iris_test AS InputTable PARTITION BY id
  USING
    TopK (3)
) AS dt ORDER BY id, prob DESC;

Output

The output table shows the dimensions and id of each sample, and the probability that it belongs to each of the three clusters.

 id  sepal_length sepal_width petal_length petal_width cluster_rank cluster_id prob                   
 --- ------------ ----------- ------------ ----------- ------------ ---------- ---------------------- 
   5          5.0         3.6          1.4         0.2            1          0     0.9999999999999989
   5          5.0         3.6          1.4         0.2            2          2 1.0698003688064299E-15
   5          5.0         3.6          1.4         0.2            3          1  8.212771939415291E-29
  10          4.9         3.1          1.5         0.1            1          0     0.9999999999999949
  10          4.9         3.1          1.5         0.1            2          2  5.215047489403572E-15
  10          4.9         3.1          1.5         0.1            3          1  8.596087853138194E-24
  15          5.8         4.0          1.2         0.2            1          0     0.9999999999998073
  15          5.8         4.0          1.2         0.2            2          2 1.9283604401940617E-13
  15          5.8         4.0          1.2         0.2            3          1  2.023083459936497E-35
  20          5.1         3.8          1.5         0.3            1          0     0.9999999999999865
  20          5.1         3.8          1.5         0.3            2          2 1.3581233688332843E-14
  20          5.1         3.8          1.5         0.3            3          1 3.5015069719597627E-28
  25          4.8         3.4          1.9         0.2            1          0     0.9999999999990372
  25          4.8         3.4          1.9         0.2            2          2  9.628706763468497E-13
  25          4.8         3.4          1.9         0.2            3          1  2.258612841490787E-19
  30          4.7         3.2          1.6         0.2            1          0     0.9999999999999887
  30          4.7         3.2          1.6         0.2            2          2 1.1240537970056623E-14
  30          4.7         3.2          1.6         0.2            3          1  9.676416490528892E-23
  35          4.9         3.1          1.5         0.2            1          0     0.9999999999999918
  35          4.9         3.1          1.5         0.2            2          2   8.12474270733355E-15
  35          4.9         3.1          1.5         0.2            3          1 4.1669847147126875E-23
  40          5.1         3.4          1.5         0.2            1          0     0.9999999999999916
  40          5.1         3.4          1.5         0.2            2          2  8.454813076593314E-15
  40          5.1         3.4          1.5         0.2            3          1  3.446661810603676E-25
  45          5.1         3.8          1.9         0.4            1          0      0.999999999988463
  45          5.1         3.8          1.9         0.4            2          2 1.1536928120751568E-11
  45          5.1         3.8          1.9         0.4            3          1  4.013220603920191E-21
  50          5.0         3.3          1.4         0.2            1          0     0.9999999999999982
  50          5.0         3.3          1.4         0.2            2          2 1.6654268270139521E-15
  50          5.0         3.3          1.4         0.2            3          1  3.429446069942643E-26
  55          6.5         2.8          4.6         1.5            1          2     0.9999999999990403
  55          6.5         2.8          4.6         1.5            2          1   9.59569181252332E-13
  55          6.5         2.8          4.6         1.5            3          0  5.569025600510225E-38
  60          5.2         2.7          3.9         1.4            1          1     0.9442250899448984
  60          5.2         2.7          3.9         1.4            2          2   0.055774910055101865
  60          5.2         2.7          3.9         1.4            3          0 3.1599350623031505E-20
  65          5.6         2.9          3.6         1.3            1          1      0.846860212056736
  65          5.6         2.9          3.6         1.3            2          2     0.1531397879432626
  65          5.6         2.9          3.6         1.3            3          0 1.2234934358485754E-15
  70          5.6         2.5          3.9         1.1            1          1     0.9465447895583854
  70          5.6         2.5          3.9         1.1            2          2   0.053455210441614366
  70          5.6         2.5          3.9         1.1            3          0 1.1208865308842914E-20
  75          6.4         2.9          4.3         1.3            1          2     0.9999999950777232
  75          6.4         2.9          4.3         1.3            2          1  4.9222768050956666E-9
  75          6.4         2.9          4.3         1.3            3          0 2.1848015795180576E-30
  80          5.7         2.6          3.5         1.0            1          1     0.9917937569411431
  80          5.7         2.6          3.5         1.0            2          2   0.008206243058854052
  80          5.7         2.6          3.5         1.0            3          0 2.8538614115610594E-15
  85          5.4         3.0          4.5         1.5            1          2      0.999987668251635
  85          5.4         3.0          4.5         1.5            2          1  1.2331748365215967E-5
  85          5.4         3.0          4.5         1.5            3          0  3.218903379735191E-29
  90          5.5         2.5          4.0         1.3            1          1     0.8465631916397747
  90          5.5         2.5          4.0         1.3            2          2    0.15343680836022525
  90          5.5         2.5          4.0         1.3            3          0 1.6381671580627518E-22
  95          5.6         2.7          4.2         1.3            1          2     0.9609392973181826
  95          5.6         2.7          4.2         1.3            2          1    0.03906070268181772
  95          5.6         2.7          4.2         1.3            3          0 1.5258770448488742E-24
 100          5.7         2.8          4.1         1.3            1          2     0.9726572812010832
 100          5.7         2.8          4.1         1.3            2          1   0.027342718798916598
 100          5.7         2.8          4.1         1.3            3          0  4.573488798874464E-23
 105          6.5         3.0          5.8         2.2            1          2                    1.0
 105          6.5         3.0          5.8         2.2            2          1  7.494570350886698E-34
 105          6.5         3.0          5.8         2.2            3          0 1.6339290393405167E-67
 110          7.2         3.6          6.1         2.5            1          2                    1.0
 110          7.2         3.6          6.1         2.5            2          1 5.6048659811737865E-55
 110          7.2         3.6          6.1         2.5            3          0 2.4584327163583323E-83
 115          5.8         2.8          5.1         2.4            1          2                    1.0
 115          5.8         2.8          5.1         2.4            2          1   6.91446024044145E-19
 115          5.8         2.8          5.1         2.4            3          0 1.0620275638612122E-50
 120          6.0         2.2          5.0         1.5            1          2     0.9999999999881917
 120          6.0         2.2          5.0         1.5            2          1 1.1808581767564222E-11
 120          6.0         2.2          5.0         1.5            3          0  1.736214062469676E-44
 125          6.7         3.3          5.7         2.1            1          2                    1.0
 125          6.7         3.3          5.7         2.1            2          1 2.4157753132451544E-35
 125          6.7         3.3          5.7         2.1            3          0  1.847134529156803E-65
 130          7.2         3.0          5.8         1.6            1          2                    1.0
 130          7.2         3.0          5.8         1.6            2          1  1.309602745870143E-38
 130          7.2         3.0          5.8         1.6            3          0  7.637564893228441E-69
 135          6.1         2.6          5.6         1.4            1          2                    1.0
 135          6.1         2.6          5.6         1.4            2          1  6.916995349512563E-21
 135          6.1         2.6          5.6         1.4            3          0  7.482737218326153E-55
 140          6.9         3.1          5.4         2.1            1          2                    1.0
 140          6.9         3.1          5.4         2.1            2          1  8.867700057480836E-32
 140          6.9         3.1          5.4         2.1            3          0 3.6438229003460426E-61
 145          6.7         3.3          5.7         2.5            1          2                    1.0
 145          6.7         3.3          5.7         2.5            2          1  5.998454220109692E-39
 145          6.7         3.3          5.7         2.5            3          0 1.5286168703203913E-69
 150          5.9         3.0          5.1         1.8            1          2     0.9999999999999991
 150          5.9         3.0          5.1         1.8            2          1  9.595729554874454E-16
 150          5.9         3.0          5.1         1.8            3          0  4.913952998440134E-45

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