1.1 - 8.10 - DecisionForest Example: TreeType ('regression'), OutOfBag ('true') - 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)

This example uses the same housing data set as the previous examples. Instead of trying to predict the style of the house, this example uses homestyle as a predictor and tries to predict the price of the house. Because the response variable (price) is numeric, the TreeType is regression.

SQL Call

SELECT * FROM DecisionForest (
  ON housing_train AS InputTable
  OUT TABLE OutputTable (df_model)
  OUT TABLE OutputMessageTable (df_monitor_table)
  USING
  TreeType ('regression')
  ResponseColumn ('price') 
  NumericInputs ('lotsize','bedrooms','bathrms','stories','garagepl')
  CategoricalInputs ('homestyle','driveway','recroom','fullbase','gashw','airco','prefarea')
  MaxDepth (6) 
  MinNodeSize (2)
  NumTrees (50)
  OutOfBag ('true') 
) AS dt;

Output

 message                                          
 ------------------------------------------------ 
 Computing 50 regression trees.                  
 Each worker is computing 25 trees.              
 Each tree will contain approximately 246 points.
 Poisson sampling parameter: 1.00                
 Mean of squared residuals: 1.1802873865165223E8   
  % Var explained: 97.78732397804998             
 Decision forest created.

This query returns the following table:

SELECT task_index, tree_num, CAST (tree AS VARCHAR(50))
  FROM df_model ORDER BY 1;
task_index tree_num tree                                               
 ---------- -------- -------------------------------------------------- 
          4        0 {"sum_":1.681685E7,"sumSq_":1.4238502825E12,"size_
          4        1 {"sum_":1.727905E7,"sumSq_":1.3643563875E12,"size_
          4        2 {"sum_":1.694355E7,"sumSq_":1.3956032975E12,"size_
          4        3 {"sum_":1.908355E7,"sumSq_":1.4617931525E12,"size_
          4        4 {"sum_":1.806E7,"sumSq_":1.474040925E12,"size_":25
          4        5 {"sum_":1.63545E7,"sumSq_":1.320355595E12,"size_":
          4        6 {"sum_":1.862795E7,"sumSq_":1.4897402375E12,"size_
          4        7 {"sum_":1.759165E7,"sumSq_":1.3890647825E12,"size_
          4        8 {"sum_":1.558195E7,"sumSq_":1.2663727725E12,"size_
          4        9 {"sum_":1.537575E7,"sumSq_":1.2086245025E12,"size_
          4       10 {"sum_":1.581315E7,"sumSq_":1.1909563425E12,"size_
          4       11 {"sum_":1.75272E7,"sumSq_":1.341120065E12,"size_":
          4       12 {"sum_":1.673795E7,"sumSq_":1.3203427375E12,"size_
          4       13 {"sum_":1.703575E7,"sumSq_":1.3940797775E12,"size_
          4       14 {"sum_":1.507785E7,"sumSq_":1.1982603775E12,"size_
          4       15 {"sum_":1.538635E7,"sumSq_":1.2125508275E12,"size_
          4       16 {"sum_":1.56961E7,"sumSq_":1.259207185E12,"size_":
          4       17 {"sum_":1.892375E7,"sumSq_":1.4711988825E12,"size_
          4       18 {"sum_":1.57514E7,"sumSq_":1.28476287E12,"size_":2
          4       19 {"sum_":1.62982E7,"sumSq_":1.305691615E12,"size_":
          4       20 {"sum_":1.56613E7,"sumSq_":1.193288085E12,"size_":
          4       21 {"sum_":1.719835E7,"sumSq_":1.3850259525E12,"size_
          4       22 {"sum_":1.72148E7,"sumSq_":1.361429395E12,"size_":
          4       23 {"sum_":1.558585E7,"sumSq_":1.2253462225E12,"size_
          4       24 {"sum_":1.713935E7,"sumSq_":1.3091327925E12,"size_
          5        0 {"sum_":1.499364E7,"sumSq_":1.09838566255E12,"size
          5        1 {"sum_":1.621284E7,"sumSq_":1.21153072755E12,"size
          5        2 {"sum_":1.584329E7,"sumSq_":1.20964782505E12,"size
          5        3 {"sum_":1.8707295E7,"sumSq_":1.446280402525E12,"si
          5        4 {"sum_":1.66777E7,"sumSq_":1.261864825E12,"size_":
          5        5 {"sum_":1.641145E7,"sumSq_":1.3340593525E12,"size_
          5        6 {"sum_":1.791324E7,"sumSq_":1.35688597255E12,"size
          5        7 {"sum_":1.57669E7,"sumSq_":1.177536645E12,"size_":
          5        8 {"sum_":1.4742645E7,"sumSq_":1.112824970025E12,"si
          5        9 {"sum_":1.548094E7,"sumSq_":1.19681165255E12,"size
          5       10 {"sum_":1.6602745E7,"sumSq_":1.345563175025E12,"si
          5       11 {"sum_":1.696595E7,"sumSq_":1.2466159725E12,"size_
          5       12 {"sum_":1.6895545E7,"sumSq_":1.356572220025E12,"si
          5       13 {"sum_":1.630075E7,"sumSq_":1.2469239875E12,"size_
          5       14 {"sum_":1.43426E7,"sumSq_":1.07212618E12,"size_":2
          5       15 {"sum_":1.4557895E7,"sumSq_":1.101687512525E12,"si
          5       16 {"sum_":1.4730795E7,"sumSq_":1.099434292525E12,"si
          5       17 {"sum_":1.824529E7,"sumSq_":1.39450218005E12,"size
          5       18 {"sum_":1.510695E7,"sumSq_":1.1471032125E12,"size_
          5       19 {"sum_":1.5264045E7,"sumSq_":1.125377830025E12,"si
          5       20 {"sum_":1.6693645E7,"sumSq_":1.395296370025E12,"si
          5       21 {"sum_":1.5762345E7,"sumSq_":1.110753800025E12,"si
          5       22 {"sum_":1.748599E7,"sumSq_":1.34602377005E12,"size
          5       23 {"sum_":1.5813695E7,"sumSq_":1.199732752525E12,"si
          5       24 {"sum_":1.6980695E7,"sumSq_":1.333814232525E12,"si

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