LIGHTGRADBOOST Procedure
Getting Started: LIGHTGRADBOOST 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 light gradient boosting machine (LightGBM) 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 LightGBM model that scores 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 |
For this example, the statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref. You can load the hmeq data set into your SAS library in the following DATA step:
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
| Obs | Bad | Loan | MortDue | Value | Reason | Job | YoJ | Derog | Delinq | CLAge | nInq | CLNo | DebtInc |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1100 | 25860 | 39025 | HomeImp | Other | 10.5 | 0 | 0 | 94.367 | 1 | 9 | . |
| 2 | 1 | 1300 | 70053 | 68400 | HomeImp | Other | 7.0 | 0 | 2 | 121.833 | 0 | 14 | . |
| 3 | 1 | 1500 | 13500 | 16700 | HomeImp | Other | 4.0 | 0 | 0 | 149.467 | 1 | 10 | . |
| 4 | 1 | 1500 | . | . | . | . | . | . | . | . | . | ||
| 5 | 0 | 1700 | 97800 | 112000 | HomeImp | Office | 3.0 | 0 | 0 | 93.333 | 0 | 14 | . |
| 6 | 1 | 1700 | 30548 | 40320 | HomeImp | Other | 9.0 | 0 | 0 | 101.466 | 1 | 8 | 37.1136 |
| 7 | 1 | 1800 | 48649 | 57037 | HomeImp | Other | 5.0 | 3 | 2 | 77.100 | 1 | 17 | . |
| 8 | 1 | 1800 | 28502 | 43034 | HomeImp | Other | 11.0 | 0 | 0 | 88.766 | 0 | 8 | 36.8849 |
| 9 | 1 | 2000 | 32700 | 46740 | HomeImp | Other | 3.0 | 0 | 2 | 216.933 | 1 | 12 | . |
| 10 | 1 | 2000 | . | 62250 | HomeImp | Sales | 16.0 | 0 | 0 | 115.800 | 0 | 13 | . |
PROC LIGHTGRADBOOST treats numeric variables as interval inputs unless you specify otherwise. Character variables are always treated as nominal inputs. The following statements run PROC LIGHTGRADBOOST and save the model in a table named mylib.lgbmStore:
proc lightgradboost data=mylib.hmeq validdata=mylib.hmeq
boosting=DART objective=binary deterministic;
input Delinq Derog Job nInq Reason / level = nominal;
input CLAge CLNo DebtInc Loan Mortdue Value YoJ / level = interval;
target Bad / level = nominal;
SAVESTATE RSTORE=mylib.lgbmStore ;
output out=mylib.procout copyvars=(bad loan reason);
ods output IterHistory=IterHistory;
run;
No parameters are specified in the PROC LIGHTGRADBOOST 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 255.
The INPUT and TARGET statements are required in order to run PROC LIGHTGRADBOOST. 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 model.
Figure 2: Model Information
| Model Information | |
|---|---|
| cValue | |
| Boosting Method | dart |
| Objective Type | binary |
| Number of Bins | 255 |
| Minimum Leaf Size | 20 |
| Lasso (L1) Penalty | 0 |
| Ridge (L2) Penalty | 0 |
| Maximum Categories | 32 |
Figure 3 displays the "Number of Observations" table, which shows how many observations were read and used.
Figure 3: Number of Observations
| Number of Observations | |
|---|---|
| Number of Training Observations Read | 5960 |
| Number of Training Observations Used | 5960 |
| Number of Validation Observations Read | 5960 |
| Number of Validation Observations Used | 5960 |
Figure 4 displays the "Iteration History" table, which shows evaluation for training and validation data.
Figure 4: Iteration History
| Iteration History | ||
|---|---|---|
| Number of Trees | Training Accuracy Metric | Validation Accuracy Metric |
| 1 | 0.455459 | 0.455459 |
| 2 | 0.423271 | 0.423271 |
| 3 | 0.396965 | 0.396965 |
| 4 | 0.374807 | 0.374807 |
| 5 | 0.357085 | 0.357085 |
| 6 | 0.359752 | 0.359752 |
| 7 | 0.344340 | 0.344340 |
| 8 | 0.330293 | 0.330293 |
| 9 | 0.317816 | 0.317816 |
| 10 | 0.305986 | 0.305986 |
| . | . | . |
| . | . | . |
| . | . | . |
| 91 | 0.190224 | 0.190224 |
| 92 | 0.191454 | 0.191454 |
| 93 | 0.188470 | 0.188470 |
| 94 | 0.188844 | 0.188844 |
| 95 | 0.185942 | 0.185942 |
| 96 | 0.186890 | 0.186890 |
| 97 | 0.183837 | 0.183837 |
| 98 | 0.185237 | 0.185237 |
| 99 | 0.187095 | 0.187095 |
| 100 | 0.188650 | 0.188650 |
Figure 5 displays the "Encoded Name Information" table, which shows the names of predicted probabilities.
Figure 5: Encoded Name Information
| Encoded Name Information | ||
|---|---|---|
| Level Name | Level ID | Variable Name |
| 0 | 0 | P_Bad0 |
| 1 | 1 | P_Bad1 |