PARTIALDEPEND Procedure
Getting Started: PARTIALDEPEND 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 illustrates some of the basic features of the PARTIALDEPEND procedure by analyzing a gradient boosting model that is trained on the cars data table.
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 a PD plot with ODS Graphics enabled:
ods graphics on; /* Enables ODS Graphics */
ods output PartialDependence = pd_table; /* Saves the ODS table */
proc PartialDepend data = mylib.cars seed = 12345;
input Cylinders Horsepower MSRP / level = interval;
input Origin Type / level = nominal;
predictedTarget P_MPG_City;
analysisVariable Type;
astoreModel rstore = mylib.gbStore_cars;
run;
The DATA= option specifies the data table to use for PD analysis. 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 Type 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.
Figure 1 displays the average predicted city mileage by each level of the Type variable. Figure 2 displays the average predicted city mileage by Type level as a plot. It also displays the number of observations for each level of the analysis variable in the sampled data (labeled as "Count") at the bottom of the plot.
Figure 1: Partial Dependence Table
| Partial Dependence | ||||
|---|---|---|---|---|
| Bin (Type) | Type | Mean Prediction (P_MPG_City) | Standard Error (P_MPG_City) | Count |
| 1 | Sedan | 20.50570829 | 0.1910949728 | 262 |
| 2 | SUV | 17.914748769 | 0.2014259473 | 60 |
| 3 | Sports | 21.112282551 | 0.2227940166 | 49 |
| 4 | Wagon | 20.143071169 | 0.2220553717 | 30 |
| 5 | Truck | 18.651004329 | 0.2489319097 | 24 |
| 6 | Hybrid | 24.392705139 | 0.3452386778 | 3 |
Figure 2: Partial Dependence Plot
