16.20 - DecisionTreePredict Example: Apply Model to Test Data - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ - NewSQL Engine Analytic Functions

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Release Date
July 2019
Content Type
Programming Reference
Publication ID
B035-1206-162K
Language
English (United States)

SQL Call

CREATE MULTISET TABLE decisiontree_predict AS (
  SELECT * FROM DecisionTreePredict (
    ON iris_attribute_test AS AttributeTable PARTITION BY pid
      ORDER BY attribute
    ON iris_attribute_output as Model DIMENSION
    USING
    AttrTableGroupbyColumns ('attribute')
    AttrTablePIDColumns ('pid')
    AttrTableValColumn ('attrvalue')
  ) AS dt
) WITH DATA;

Output

This query returns the following table:

SELECT * FROM decisiontree_predict ORDER BY 1;

The predict labels 1, 2, and 3 correspond to species setosa, versicolor, and virginica.

pid pred_label
5 1
10 1
15 1
20 1
25 1
30 1
35 1
40 1
45 1
50 1
55 2
60 2
65 2
70 2
75 2
80 2
85 2
90 2
95 2
100 2
105 3
110 3
115 3
120 2
125 3
130 2
135 2
140 3
145 3
150 3