PARTIALDEPEND Procedure
Example 28.1 Compute Partial Dependence for an Interval Target Variable
This example shows how to use the PARTIALDEPEND procedure to estimate the partial dependence (PD) function for an interval target variable.
The following DATA step creates the input data table mylib.cars. These statements assume that your CAS engine libref is named mylib, but you can substitute any appropriately defined CAS engine libref.
data mylib.cars;
set sashelp.cars;
run;
The following statements run the GRADBOOST procedure to build a gradient boosting model to predict city gas mileage for each automobile in the mylib.cars data table. The procedure also outputs an analytic store named gbStore_cars.
proc gradboost data = mylib.cars seed = 12345;
input Cylinders Horsepower MSRP / level = interval;
input Origin Type / level = nominal;
target MPG_City / level = interval;
saveState rstore = mylib.gbStore_cars;
run;
The following statements run PROC PARTIALDEPEND and produce the PD plot with ODS Graphics enabled:
ods graphics on; /* Enables ODS Graphics */
proc PartialDepend data = mylib.cars replicateType = MIDPOINTS seed = 12345;
input Cylinders Horsepower MSRP / level = interval;
input Origin Type / level = nominal;
predictedTarget P_MPG_City;
analysisVariable Horsepower;
astoreModel rstore = mylib.gbStore_cars;
run;
The DATA= option specifies the data table to use for PD analysis. The REPLICATETYPE= option replicates bin midpoints for the analysis variable. The SEED= option specifies the seed to use for pseudorandom number generation. The two INPUT statements specify that the Cylinders, Horsepower, MSRP, Origin, and Type variables be used as inputs. The PREDICTEDTARGET statement specifies that the P_MPG_City variable be used as the predicted target. The ANALYSISVARIABLE statement specifies that the Horsepower variable be used as the analysis variable. The ASTOREMODEL statement with the RSTORE= option specifies that the analytic store saved in the data table mylib.gbStore_cars be used as the model for analysis.
Output 28.1.1 displays the average predicted city mileage by each binned Horsepower value. Output 28.1.2 displays the average predicted city mileage by Horsepower as a plot. It also displays the number of observations for each bin of the analysis variable in the sampled data (labeled as "Count") at the bottom of the plot.
Output 28.1.1: Partial Dependence Table
| Partial Dependence | ||||
|---|---|---|---|---|
| Bin (Horsepower) | Horsepower | Mean Prediction (P_MPG_City) | Standard Error (P_MPG_City) | Count |
| 1 | 94.35 | 36.4692088 | 0.1233019178 | 24 |
| 2 | 137.05 | 25.644018663 | 0.1181638873 | 68 |
| 3 | 179.75 | 19.489612639 | 0.1110720415 | 110 |
| 4 | 222.45 | 19.10767521 | 0.1118359726 | 108 |
| 5 | 265.15 | 19.079890007 | 0.1103457652 | 42 |
| 6 | 307.85 | 17.900404766 | 0.1099332326 | 50 |
| 7 | 350.55 | 17.518976898 | 0.1136050818 | 15 |
| 8 | 393.25 | 17.256772898 | 0.1199480112 | 4 |
| 9 | 435.95 | 17.256772898 | 0.1199480112 | 2 |
| 10 | 478.65 | 17.256772898 | 0.1199480112 | 5 |
Output 28.1.2: Partial Dependence Plot
