DecisionForestPredict Function Example | Teradata Vantage - DecisionForestPredict Example: Specify Column Range, OutputProb, Responses - Teradata® Database

Database Analytic Functions

Product
Teradata® Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
Teradata_Vantage™___Advanced_SQL_Engine_Analytic_Functions.withLogo_upload_July2021/wnd1589838592459.ditamap
dita:ditavalPath
Teradata_Vantage™___Advanced_SQL_Engine_Analytic_Functions.withLogo_upload_July2021/ayr1485454803741.ditaval
dita:id
B035-1206
lifecycle
previous
Product Category
Teradata Vantage™

Input

  • Input table: housing_test_sample
     sn                  price                lotsize  bedrooms  bathrms  stories  driveway  recroom  fullbase  gashw  airco  garagepl  prefarea  homestyle
    ---  ---------------------  ---------------------  --------  -------  -------  --------  -------  --------  -----  -----  --------  --------  ---------
    329  1.15442000000000E 005  7.00000000000000E 003         3        2        4  yes       no       no        no     yes           2  no        bungalow
    224  7.85000000000000E 004  2.81700000000000E 003         4        2        2  no        yes      yes       no     no            1  no        Eclectic
    198  4.05000000000000E 004  4.35000000000000E 003         3        1        2  no        no       no        yes    no            1  no        Classic
    162  1.30000000000000E 005  6.00000000000000E 003         4        1        2  yes       no       yes       no     no            2  no        bungalow
    339  1.41000000000000E 005  8.10000000000000E 003         4        1        2  yes       yes      yes       no     yes           2  yes       bungalow
  • Model: rft_model_classification
    worker_ip      task_index  tree_num  tree
    -------------  ----------  --------  ----
    172.24.57.209           1         0  {"responseCounts_":{"classic":48,"bungalow":21,"eclectic":97},
    172.24.96.213           0         0  {"responseCounts_":{"classic":48,"bungalow":17,"eclectic":99},
    172.24.106.80           2         0  {"responseCounts_":{"classic":40,"bungalow":16,"eclectic":108},
    172.24.57.209           1         1  {"responseCounts_":{"classic":73,"bungalow":30,"eclectic":107},
    172.24.96.213           0         1  {"responseCounts_":{"classic":66,"bungalow":23,"eclectic":114},
    172.24.106.80           2         1  {"responseCounts_":{"classic":65,"bungalow":24,"eclectic":115},
    172.24.57.209           1         2  {"responseCounts_":{"classic":61,"bungalow":19,"eclectic":80},
    172.24.96.213           0         2  {"responseCounts_":{"classic":47,"bungalow":18,"eclectic":93},
    172.24.106.80           2         2  {"responseCounts_":{"classic":53,"bungalow":8,"eclectic":97},

    (In the preceding screen, tree column is truncated on the right.)

SQL Call

SELECT * FROM DecisionForestPredict (
  ON housing_test_sample PARTITION BY ANY
  ON rft_model_classification AS Model DIMENSION
  USING
  NumericInputs ('[1:5]','garagepl')
  CategoricalInputs ('[6:10]','prefarea')
  IdColumn ('sn')
  Accumulate ('homestyle')
  Detailed ('false')
  OutputProb ('t')
  Responses ('classic','eclectic','bungalow')

)AS dt;

Output

homestyle      sn  prediction  prob_classic  prob_eclectic  prob_bungalow
------------  ---  ----------  ------------  -------------  -------------
bungalow      329  bungalow    0.00          0.12           0.88
Eclectic      224  eclectic    0.00          1.00           0.00
Classic       198  classic     0.89          0.11           0.00
bungalow      162  bungalow    0.00          0.44           0.56
bungalow      339  bungalow    0.00          0.44           0.56