LIGHTGRADBOOST Procedure
Example 20.1 Train a LightGBM Model
This example illustrates how you can use the LIGHTGRADBOOST procedure to train a light gradient boosting machine (LightGBM) model. It uses the home equity data set Hmeq, which is in the Sampsio library.
The Hmeq data set contains 5,960 observations with 13 variables. The response variable is a binary indicator to predict which clients will default on their loan.
You can load the sampsio.hmeq data set into your CAS session by specifying your CAS engine libref in the first statement in the following DATA step:
data mylib.hmeq;
set sampsio.hmeq;
run;
These statements assume that your CAS engine libref is named mylib, as in the section Using CAS Sessions and CAS Engine Librefs, but you can substitute any appropriately defined CAS engine libref.
The following statements train a LightGBM model and score the training data table. The SAVESTATE statement creates an analytic store for the model and saves it as a binary object in the mylib.lgbmStore table. You can use the analytic store later in the ASTORE procedure for scoring.
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.lgbmout copyvars=(bad loan reason);
ods output ModelInfo=ModelInfo;
run;
The following statements use a previously saved model to score the new data table mylib.lgbmScoreout by using PROC ASTORE:
proc astore;
score data=mylib.hmeq out=mylib.lgbmScoreout rstore=mylib.lgbmStore ;
run; quit;
You can see the scoring results shown in Output 20.1.1 by using the PRINT statement:
proc print data=mylib.lgbmScoreout(obs=3);
run;
Output 20.1.1: Scoring Results from the Score File
| Obs | I_BAD | P_BAD0 | P_BAD1 |
|---|---|---|---|
| 1 | 1 | 0.16002 | 0.83998 |
| 2 | 1 | 0.25107 | 0.74893 |
| 3 | 1 | 0.11124 | 0.88876 |
In Output 20.1.1, the generated columns P_BAD0 and P_BAD1 contain the predicted probabilities of the target variable Bad with respective labels, and the generated column I_BAD contains the predicted label.