1.1 - 8.10 - XGBoost Example: Multiple-Class Classification - 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)

Input

SQL Call

SELECT * FROM XGBoost (
  ON iris_train AS InputTable
  OUT TABLE OutputTable (xgboost_model_2)
  USING
  ResponseColumn ('species')
  NumericInputs ('sepal_length','sepal_width','petal_length','petal_width')
  LossFunction ('softmax')
  IterNum (10)
  MaxDepth (10)
  MinNodeSize (1)
  RegularizationLambda (1)
  ShrinkageFactor (0.1)
  IdColumn ('id')
  NumBoostedTrees (2)
) AS dt;

Output

 message                                                          
 ---------------------------------------------------------------- 
 Parameters:                                                     
 	Number of boosting iterations : 10                             
 	Number of boosted trees : 2                                    
 	Number of total trees (all subtrees): 60                       
 	Prediction Type : CLASSIFICATION                               
 	LossFunction : SOFTMAX                                         
 	Regularization : 1.0                                           
 	Shrinkage : 0.1                                                
 	MaxDepth : 10                                                  
 	MinNodeSize : 1                                                
 	Variance : 0.0                                                 
 	Seed : null                                                    
 	ColumnSubSampling Features: 4                                  
 XGBoost model created in table specified in OutputTable argument

This query returns the following table:

SELECT tree_id, iter, class_num, CAST (tree AS VARCHAR(30)),
  CAST (region_prediction AS VARCHAR(30))
  FROM xgboost_model_2 ORDER BY 1,2,3;

For simplicity, the last two output columns show only the first 30 characters of each value.

 tree_id iter class_num tree                           region_prediction              
 ------- ---- --------- ------------------------------ ------------------------------ 
      -1   -1        -1 {"classifier":"CLASSIFICATION"                               
       0    1         0 {"sum_":-1.599999999268853E-6, {"1280":0.1142857,"64":0.06153
       0    1         1 {"sum_":-1.59999999815863E-6," {"448":-0.030769233,"1600":0.1
       0    1         2 {"sum_":-1.600000000379076E-6, {"1792":0.10526315,"512":-0.03
       0    2         0 {"sum_":0.003616429999999282," {"68":0.060082912,"69":0.03558
       0    2         1 {"sum_":-0.04985677000000033," {"194":0.060082912,"195":0.059
       0    2         2 {"sum_":0.04624057999999981,"s {"136":-0.017665762,"138":-0.0
       0    3         0 {"sum_":0.056571910000000836," {"11":0.0586718,"20":0.0346415
       0    3         1 {"sum_":-0.11455966999999945," {"768":0.033769146,"769":0.033
       0    3         2 {"sum_":0.0579888400000001,"su {"1024":-0.017285883,"65":-0.0
       0    4         0 {"sum_":-0.03785154000000013," {"386":-0.016990498,"387":-0.0
       0    4         1 {"sum_":-0.1703829400000001,"s {"384":0.03275529,"770":0.0328
       0    4         2 {"sum_":0.20823386000000021,"s {"256":-0.016856926,"257":-0.0
       0    5         0 {"sum_":-0.09160278999999949," {"906":-0.01642548,"907":-0.01
       0    5         1 {"sum_":-0.2160229899999997,"s {"64":-0.016507786,"192":0.032
       0    5         2 {"sum_":0.30762548,"sumSq_":10 {"512":-0.016685989,"257":-0.0
       0    6         0 {"sum_":-0.1034851699999998,"s {"384":-0.01644111,"385":-0.01
       0    6         1 {"sum_":-0.24224078999999943," {"64":-0.01621804,"192":0.0313
       0    6         2 {"sum_":0.3457257400000001,"su {"256":-0.016269337,"257":-0.0
       0    7         0 {"sum_":-0.10058686000000011," {"10":0.048104186,"17":0.04934
       0    7         1 {"sum_":-0.27628428000000027," {"64":-0.01593128,"192":0.0307
       0    7         2 {"sum_":0.37687089999999995,"s {"390":0.03144228,"391":0.0314
       0    8         0 {"sum_":-0.09390170000000037," {"10":0.04639392,"17":0.047569
       0    8         1 {"sum_":-0.31455724000000007," {"1792":-0.015894378,"897":-0.
       0    8         2 {"sum_":0.4084586399999995,"su {"386":0.030773884,"387":0.030
       0    9         0 {"sum_":-0.11052977999999941," {"10":0.04489386,"17":0.046010
       0    9         1 {"sum_":-0.3395179199999997,"s {"1792":-0.0156101715,"897":-0
       0    9         2 {"sum_":0.4500484600000004,"su {"386":0.030122625,"387":0.030
       0   10         0 {"sum_":-0.10063269000000047," {"8":0.029127166,"9":0.0297854
       0   10         1 {"sum_":-0.38636968000000027," {"898":-0.015284898,"390":0.02
       0   10         2 {"sum_":0.4870025499999999,"su {"1088":-0.023584498,"64":-0.0
       1    1         0 {"sum_":-1.5999999999349868E-6 {"384":-0.030769233,"1280":0.1
       1    1         1 {"sum_":-1.5999999993798752E-6 {"192":0.061538458,"1664":0.11
       1    1         2 {"sum_":-1.5999999960492062E-6 {"1920":0.10526315,"320":-0.03
       1    2         0 {"sum_":-0.008052120000000385, {"72":0.07493606,"200":-0.0384
       1    2         1 {"sum_":-0.00883190000000117," {"73":-0.017436774,"206":0.034
       1    2         2 {"sum_":0.016884240000000883," {"128":-0.029956799,"66":-0.03
       1    3         0 {"sum_":-0.019540409999999564, {"1732":-0.017137067,"1733":-0
       1    3         1 {"sum_":-0.016691220000000118, {"195":0.057706933,"388":0.034
       1    3         2 {"sum_":0.03623369999999981,"s {"68":-0.028444307,"69":-0.016
       1    4         0 {"sum_":-0.053021440000000586, {"1730":-0.016765947,"1731":-0
       1    4         1 {"sum_":-0.00979360000000018," {"196":0.05531178,"197":0.0330
       1    4         2 {"sum_":0.06281513000000005,"s {"512":-0.016650263,"513":-0.0
       1    5         0 {"sum_":-0.08495713999999971," {"8":0.052641626,"9":0.0511194
       1    5         1 {"sum_":0.0010138100000003925, {"196":0.053198207,"197":0.053
       1    5         2 {"sum_":0.0839430300000008,"su {"136":-0.027769612,"137":-0.0
       1    6         0 {"sum_":-0.11305201999999959," {"8":0.050677523,"968":-0.0165
       1    6         1 {"sum_":-0.005725930000000434, {"8":-0.026742686,"200":0.0307
       1    6         2 {"sum_":0.11877801999999904,"s {"136":-0.016474072,"138":-0.0
       1    7         0 {"sum_":-0.17543091999999988," {"966":-0.015761524,"8":0.0488
       1    7         1 {"sum_":0.034339569999999264," {"8":-0.025999688,"9":-0.02564
       1    7         2 {"sum_":0.14109133999999945,"s {"64":-0.02624011,"65":-0.0254
       1    8         0 {"sum_":-0.20581622000000027," {"962":-0.015481344,"963":-0.0
       1    8         1 {"sum_":0.05170657000000006,"s {"8":-0.025273718,"9":-0.02492
       1    8         2 {"sum_":0.15410952000000022,"s {"11":-0.025767425,"13":-0.016
       1    9         0 {"sum_":-0.2501832199999997,"s {"8":0.04542026,"9":0.04420985
       1    9         1 {"sum_":0.07305139999999949,"s {"8":-0.024565713,"9":-0.02421
       1    9         2 {"sum_":0.17713210999999962,"s {"582":-0.026058251,"70":-0.01
       1   10         0 {"sum_":-0.2820383100000005,"s {"1920":-0.033483308,"1921":-0
       1   10         1 {"sum_":0.10222440999999999,"s {"8":-0.023876363,"9":-0.02353
       1   10         2 {"sum_":0.17981347000000025,"s {"74":-0.014772956,"11":-0.015

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