GRADBOOST Procedure

Getting Started: GRADBOOST Procedure

Note: Input data must be in a CAS table that is accessible in your CAS session. You must refer to this table by using a two-level name. The first level must be a CAS engine libref, and the second level must be the table name. For more information, see the sections Using CAS Sessions and CAS Engine Librefs and Loading a SAS Data Set onto a CAS Server in Chapter 2, Shared Concepts.

A common use of gradient boosting models is to predict whether a mortgage applicant will default on a loan. The home equity data table Hmeq, which is in the Sampsio library that SAS provides, contains observations for 5,960 mortgage applicants. A variable named Bad indicates whether the applicant, after being approved for a loan, paid off or defaulted on the loan.

This example uses the Hmeq data table to build a gradient boosting model that is used to score the data and can be used to score data about new loan applicants. Table 1 describes the variables in Hmeq.

Table 1: Variables in the Home Equity (Hmeq) Data Table

Variable Role Level Description
Bad Response Binary 1 = applicant defaulted on the loan or is seriously delinquent
0 = applicant paid off the loan
CLAge Predictor Interval Age of oldest credit line in months
CLNo Predictor Interval Number of credit lines
DebtInc Predictor Interval Debt-to-income ratio
Delinq Predictor Interval Number of delinquent credit lines
Derog Predictor Interval Number of major derogatory reports
Job Predictor Nominal Occupational category
Loan Predictor Interval Requested loan amount
MortDue Predictor Interval Amount due on mortgage
nInq Predictor Interval Number of recent credit inquiries
Reason Predictor Binary DebtCon = debt consolidation
HomeImp = home improvement
Value Predictor Interval Value of property
YoJ Predictor Interval Years at present job


The following statements load the mylib.hmeq data into your CAS session. For this example, the statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref.

data mylib.hmeq;
   length Bad Loan MortDue Value 8 Reason Job $7
              YoJ Derog Delinq CLAge nInq CLNo DebtInc 8;
   set sampsio.hmeq;
run;

proc print data=mylib.hmeq(obs=10); run;

Figure 1 shows the first 10 observations of mylib.hmeq.

Figure 1: Partial Listing of the mylib.hmeq Data

ObsBadLoanMortDueValueReasonJobYoJDerogDelinqCLAgenInqCLNoDebtInc
1111002586039025HomeImpOther10.50094.36719.
211500..  .......
3118004864957037HomeImpOther5.03277.100117.
412000.62250HomeImpSales16.000115.800013.
5120004500055000HomeImpOther3.00086.067225.
6122002428034687HomeImpOther.01300.86708.
7123002819240150HomeImpOther4.50054.600116.
8124005000073395HomeImpProfExe5.010.10.
912400.17180HomeImpOther.0014.56734.
10125001500020200HomeImp 18.000136.067119.


PROC GRADBOOST treats numeric variables as interval inputs unless you specify otherwise. Character variables are always treated as nominal inputs. The following statements run PROC GRADBOOST and save the model in a table named mylib.savedModel:

proc gradboost data=mylib.hmeq outmodel=mylib.savedModel seed=12345;
   input Delinq Derog Job nInq Reason / level = nominal;
   input CLAge CLNo DebtInc Loan Mortdue Value YoJ / level = interval;
   target Bad / level = nominal;
   ods output FitStatistics=fitstats;
run;

No parameters are specified in the PROC GRADBOOST statement; therefore, the procedure uses all default values. For example, the number of trees in the boosting model is 100, and the number of bins for interval input variables is 20.

The INPUT and TARGET statements are required in order to run PROC GRADBOOST. The INPUT statement indicates which variables to use to build the model, and the TARGET statement indicates which variable the procedure predicts.

Figure 2 displays the "Model Information" table. This table shows the values of the training parameters in the first six rows, in addition to some basic information about the trees in the boosting model.

Figure 2: Model Information

The GRADBOOST Procedure

Model Information
Number of Trees100
Learning Rate0.1
Subsampling Rate0.5
Number of Variables Per Split12
Number of Bins50
Number of Input Variables12
Maximum Number of Tree Nodes31
Minimum Number of Tree Nodes17
Maximum Number of Branches2
Minimum Number of Branches2
Maximum Depth4
Minimum Depth4
Maximum Number of Leaves16
Minimum Number of Leaves9
Maximum Leaf Size2603
Minimum Leaf Size5
Seed12345
Lasso (L1) penalty0
Ridge (L2) penalty1
Actual Number of Trees100
Average Number of Leaves14.17


Figure 3 displays the "Number of Observations" table, which shows how many observations were read and used. If you specify a PARTITION statement, the "Number of Observations" table also displays the number of observations that were read and used per partition.

Figure 3: Number of Observations

 Training
Number of Observations Read5960
Number of Observations Used5960


Figure 4 displays the estimates of variable importance. The rows in this figure are sorted by the importance measure. A conclusion from fitting the boosting model to these data is that DebtInc is the most important predictor of loan default.

Figure 4: Variable Importance

Variable Importance
VariableImportanceStd Dev
Importance
Relative
Importance
DebtInc27.904477.61221.0000
Delinq5.72507.34210.2052
Value5.51425.97900.1976
CLAge5.38505.99200.1930
Derog4.08954.93820.1466
CLNo3.34993.15600.1201
Job3.06412.64630.1098
YoJ2.86282.95810.1026
Loan2.71762.98250.0974
MortDue2.59792.77250.0931
nInq1.90702.48520.0683
Reason0.39631.00040.0142


Figure 5 shows the first 10 and last 10 observations of the fit statistics. PROC GRADBOOST computes fit statistics on a per-tree basis. As the number of trees increases, the fit statistics usually improve (decrease) at first and then level off and fluctuate within a small range.

Figure 5: Fit Statistics

Fit Statistics
Number
of Trees
Training
Average
Square Error
Training
Misclassification
Rate
Training
Log Loss
10.14580.19950.459
20.13520.19950.431
30.12580.19950.407
40.11860.19950.388
50.11250.19730.372
60.10760.18270.360
70.10320.15670.348
80.09950.13610.338
90.09610.12500.329
100.09300.11900.320
....
....
....
910.04810.06490.172
920.04770.06460.170
930.04740.06480.170
940.04720.06360.169
950.04690.06440.168
960.04670.06290.167
970.04630.06260.166
980.04600.06160.165
990.04570.06110.164
1000.04560.05970.164


Last updated: September 04, 2026