GRADBOOST Procedure
Example 16.3 Tuning a Boosting Model
This example illustrates how you can use the AUTOTUNE statement in the GRADBOOST procedure to tune a boosting model. It uses the JunkMail data set in the Sashelp library.
The JunkMail data set comes from a study that classifies whether an email is junk email (coded as 1) or not (coded as 0). The data set contains 4,601 observations with 59 variables. The response variable is a binary indicator of whether an email is considered spam or not. There are 57 predictor variables that record the frequencies of some common words and characters and the lengths of uninterrupted sequences of capital letters in emails.
You can load the Sashelp.JunkMail data set into your SAS library by naming your SAS libref in the first statement of the following DATA step:
data mylib.junkmail;
set sashelp.junkmail;
run;
These statements assume that your SAS libref is named mylib, but you can substitute any appropriately defined libref.
The following statements use the AUTOTUNE statement in PROC GRADBOOST to run a tuning process on a boosting model:
ods graphics on;
proc gradboost data=mylib.junkmail outmodel=mylib.gradboost_model seed=12345;
input Address Addresses All Bracket Business CS CapAvg CapLong
CapTotal Conference Credit Data Direct Dollar Edu Email
Exclamation Font Free George HP HPL Internet Lab Labs
Mail Make Meeting Money Order Original Our Over PM Paren
Parts People Pound Project RE Receive Remove Semicolon
Table Technology Telnet Will You Your _000 _85 _415 _650
_857 _1999 _3D / level = interval;
target class /level=nominal;
autotune
/* Tuning Parameters
You do not need to specify any tuning parameters for the default
tuning process. If you want to make adjustments to the default
tuning process, uncomment the following block of code and change
any of the tuning parameters' attributes.
tuningParameters=(
BINMETHOD (exclude)
LASSO (lb=0.0 ub=10.0 init=0.0 )
LEARNINGRATE (lb=0.01 ub=1.0 init=0.1 )
MAXDEPTH (lb=2 ub=7 init=5 )
MINLEAFSIZE (values=1 5 10 20 40 80 160 320 init=5 exclude)
NTREES (lb=20 ub=150 init=100 )
NUMBIN (lb=20 ub=100 init=50 )
RIDGE (lb=0.0 ub=10.0 init=1.0 )
SAMPLINGRATE (lb=0.1 ub=1.0 init=0.5 )
VARS_TO_TRY (lb=1 ub=56 init=7 )
)
*/
;
/* Remove this line to see all results */
ods select BestConfiguration EvaluationHistoryPlot IterationHistoryPlot;
run;
The preceding statements produce the table and the plots shown in Output 16.3.1 through Output 16.3.3. The table in Output 16.3.1 displays the evaluation number, the values of the tuning parameters, and the error metric value for the best decision tree model that the tuner found. Note that the ODS SELECT statement limits the displayed results to a single table and two plots. You can remove this statement to display all tables and plots. For the full list of ODS tables that PROC GRADBOOST produces, see Table 6.
Output 16.3.1: Best Configuration Table
| Best Configuration | |
|---|---|
| Evaluation | 80 |
| Number of Variables to Try | 43 |
| Learning Rate | 0.505 |
| Sampling Rate | 0.55 |
| Lasso | 2.5 |
| Ridge | 5 |
| Number of Bins | 60 |
| Maximum Tree Levels | 7 |
| Misclassification Error Percentage | 4.13 |
Output 16.3.2 displays a scatter plot of all configurations that the tuner tried. The objective values are shown on the Y axis, and the evaluation numbers are shown on the X axis.
Output 16.3.2: Evaluation History Plot

The plot in Output 16.3.3 displays how the best found objective value and the elapsed time changed with each iteration of the tuner.
Output 16.3.3: Iteration History Plot

Note: Input data must be in a table that is accessible in your session. You can refer to this table by using a two-level name. The first level is a libref, and the second level is the table name. For more information, see the section Using SAS Viya Workbench in Chapter 2, Shared Concepts.