DecisionTreePredict Function Example | Teradata Vantage - 17.05 - DecisionTreePredict Example: Apply Model to Test Data - Teradata Database

Teradata Vantage™ - Advanced SQL Engine Analytic Functions

prodname
Advanced SQL Engine
Teradata Database
vrm_release
17.00
17.05
created_date
June 2020
category
Programming Reference
featnum
B035-1206-170K

SQL Call

CREATE MULTISET TABLE decisiontree_predict AS (
  SELECT * FROM DecisionTreePredict (
    ON iris_attribute_test AS AttributeTable PARTITION BY pid
    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