PARTIALDEPEND Procedure

Example 28.3 Compute a Two-Way Partial Dependence Function

This example shows how to use the PARTIALDEPEND procedure to estimate the partial dependence (PD) function for two analysis variables.

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 output 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 Type;
   analysisVariable Cylinders / min = 3 max = 9 nBins = 3;
   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 any numeric 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 first ANALYSISVARIABLE statement specifies that the Type variable be used as an analysis variable. The second ANALYSISVARIABLE statement specifies that the Cylinders variable be used as the second analysis variable. Because Cylinders is an interval variable, its values are binned. The MIN= and MAX= options specify the range of values to bin. The NBINS= option requests three bins. 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.3.1 displays the average predicted mileage for each combination of values of the two analysis variables. It also displays the counts of observations for each combination of values in the sampled data table. Some counts are 0 because the specific combinations do not exist in the sampled training data.

Output 28.3.1: Partial Dependence Table

The PARTIALDEPEND Procedure

Partial Dependence
Bin (Type)Bin2 (Cylinders)TypeCylindersMean Prediction (P_MPG_City)Standard Error (P_MPG_City)Count
11Sedan421.7890415650.154275592796
12Sedan620.235813130.1617475483126
13Sedan819.2598878950.174595816340
21SUV419.4720210890.15629240527
22SUV617.8101323470.171133788230
23SUV816.3205531880.188476994223
31Sports421.9907651840.198387982411
32Sports621.0043529550.202339846320
33Sports819.9733041910.214745709316
41Wagon421.2281801890.188448220114
42Wagon620.0808573210.195052309712
43Wagon818.8402635060.21305018564
51Truck420.7548989630.19518559846
52Truck617.9330890250.20851778339
53Truck817.2110597070.21559608479
61Hybrid426.5985805760.28592719123
62Hybrid623.6933279730.29367678640
63Hybrid822.5073436230.30840826440


Last updated: August 06, 2026