LIME Procedure
Getting Started: LIME 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.
This example uses the LIME procedure to explain a prediction that is made by a forest model.
The following DATA step creates the input data table mylib.dmagecr. These statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref.
data mylib.dmagecr;
set sampsio.dmagecr;
id = _N_;
keep age amount coapp duration foreign job good_bad id;
run;
The following DATA step creates the query data table mylib.query in your CAS session:
data mylib.query;
set sampsio.dmagecr;
keep age amount coapp duration foreign job good_bad;
if _N_ = 20;
run;
The following statements use the FOREST procedure to build a forest model to predict whether the credit rating of each individual in the mylib.dmagecr data table is good or bad. The procedure also outputs an analytic store named forest_astore.
proc forest
data=mylib.dmagecr
seed=1234;
input age amount duration / level=interval;
input coapp foreign job /level=nominal;
target good_bad;
savestate rstore=mylib.forest_astore;
run;
The following statements run PROC LIME and produce ODS tables of the results:
proc lime
data=mylib.query
referenceData=mylib.dmagecr
seed=12345;
input age amount duration / level=interval;
input coapp foreign job /level=nominal;
predictedTarget P_good_badbad;
astoreModel rstore=mylib.forest_astore;
run;
The DATA= option names the input query data table, which specifies the data to use for LIME value calculation. The REFERENCEDATA= option names the reference data table. The SEED= option specifies the seed to use for pseudorandom number generation. The two INPUT statements specify that age, amount, and duration are the interval variables and coapp, foreign, and job are the nominal variables. The PREDICTEDTARGET statement specifies that P_good_badbad be used as the predicted target variable. The ASTOREMODEL statement specifies the analytic store that contains the model to explain.
Figure 1 displays the explainer information. Figure 2 displays the LIME values for the query observation, which are the estimated parameters of the local regression model. Figure 3 displays the explainer fidelity information.
Figure 1: Explainer Information
| Explainer Information | |
|---|---|
| Data Generation Method | Query Centered |
| Distance Method | Normalized Euclidean with Exponential Kernel |
| Explainer Type | Regression with LASSO |
| Binary Encoding | None |
| Standardize Parameter Estimates | None |
| Include Missing as a Level | No |
| Number of Samples | 3000 |
| Exponential Kernel Divisor | 1.8371173071 |
| Mixed Distance Weight | 1 |
| Seed | 12345 |
Figure 2: Parameter Estimates
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Variable | Nominal Variables | Estimate | Query Level | ||
| coapp | foreign | job | |||
| Intercept | . | . | . | 0.3190324769 | . |
| age | . | . | . | -0.005548298 | 31 |
| amount | . | . | . | -5.169254E-6 | 3430 |
| duration | . | . | . | 0.0067004505 | 24 |
| coapp | 2 | . | . | 0.1128066607 | 0 |
| coapp | 3 | . | . | -0.039284815 | 0 |
| coapp | 1 | . | . | 0 | 1 |
| foreign | . | 2 | . | -0.155467523 | 0 |
| foreign | . | 1 | . | 0 | 1 |
| job | . | . | 1 | 0.0752579772 | 0 |
| job | . | . | 2 | 0.0391428793 | 0 |
| job | . | . | 3 | 0 | 1 |
Figure 3: Explainer Fidelity
| Explainer Fidelity | ||
|---|---|---|
| Model Prediction | Explainer Prediction | Explainer RMSE |
| 0.3276871873 | 0.2901154994 | 0.0947577628 |