GPCLASS Procedure

Example 15.2 Tuning the Hyperparameters of a Gaussian Process Classification Model

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 Toy data set to demonstrate how to use the AUTOTUNE statement in the GPCLASS procedure to automatically tune the hyperparameters of a Gaussian process classification model.

The Toy data set contains 40 observations and three variables. The variable label contains the two binary classes 1 and 0, and the other two numeric variables contain statistics about the location.

The following DATA steps load the Toy data set into your CAS session and then divide the data into the training data table and the testing data table. PROC GPCLASS then uses the first data table for training and the second data table for testing. These statements assume that your libref is named mylib, but you can substitute any appropriately named libref.

data toy;
   input id x y label;
   datalines;
   1 0.7562437251693241 -0.4449246304395207 1
   2 1.6425910060420805 -0.10293958159084055 1
   3 0.5036628219528629 -0.3756019302569773 1
   4 1.9356458876375808 0.1508435933753537 1
   5 -0.48929352371915874 0.9004153510746639 0
   6 1.9612377920931525 0.3688561398322367 1
   7 -0.4457973476327784 0.923703991351446 0
   8 0.897645351230446 0.13625291562699787 0
   9 1.0428050419382913 0.2538945316161072 0
   10 1.7841025147461618 -0.03250971343343456 1
   11 0.6525149362580007 -0.5043431552576471 1
   12 1.8526407982796789 0.13718466658924755 1
   13 0.7736555917316961 -0.48367703386369615 1
   14 -0.9816672335041904 0.33290929557635607 0
   15 0.24612298119546702 -0.1868663956140018 1
   16 1.99621877108224 0.3245177413955755 1
   17 -0.04791750586561572 0.2659542532295433 1
   18 2.110087224576905 0.5250574025280107 1
   19 -0.9602167257824953 0.3787188727510752 0
   20 -0.6841219033906107 0.7364079763792437 0
   21 -0.9920556836181335 0.20730041712702757 0
   22 2.0187106442510587 0.329144855526437 1
   23 -0.9363848220016563 0.5820604427678648 0
   24 0.3176242827173276 -0.23130675115061858 1
   25 -0.08766070923125874 0.9228708936342618 0
   26 0.9503505174789424 0.22930242945171128 0
   27 1.9137065930212924 0.04727138786088236 1
   28 -0.5740857513898902 0.7860024177122371 0
   29 1.7311039665579235 -0.15822368653296057 1
   30 0.15601420930527587 -0.012971094201072592 1
   31 0.03440178911461349 0.35665294277687765 1
   32 1.734352820043718 -0.16711805469096147 1
   33 0.9743086385469273 -0.03306556437399488 0
   34 1.3646032525150116 -0.33201208895864687 1
   35 -1.000588826462477 0.057717691210846855 0
   36 0.0937572740953208 -0.0973344952572724 1
   37 -0.2791878004436257 0.9850672774312587 0
   38 -0.9994507007532529 0.33048792628967455 0
   39 0.9990673318735382 -0.505133345971595 1
   40 0.8997014125100633 0.5246863891252541 0
;

data mylib.toy_train;
   set toy (obs=30);
run;

data mylib.toy_test;
   set toy(firstobs=31);
run;

The following statements use PROC GPCLASS with the AUTOTUNE statement to automatically tune the hyperparameters of a Gaussian process classification model:

proc gpclass
   data=mylib.toy_train
   testdata=mylib.toy_test
   seed=12345
   nThreads=32
   link=Logit;
   input x y;
   target label/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=(
         KERNEL    ( values=LINEAR GAUSSIAN init=GAUSSIAN )
         SIGMA     ( lb=0.01  ub=100  init=1.0 )
         CONSTANT  ( lb=0.0   ub=100  init=0.0 )
         MAXLAITER ( lb=10    ub=200  init=100 )
         THRESHOLD ( lb=1E-11 ub=1.0  init=1E-10 )
      )
      */
   ;
   /* 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 15.2.1 through Output 15.2.3. The table in Output 15.2.1 displays the evaluation number, the values of the tuning parameters, and the error metric value for the best Gaussian process classification 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 GPCLASS produces, see Table 3.

Output 15.2.1: Best Configuration Table

The GPCLASS Procedure

Best Configuration
Evaluation15
KernelLINEAR
Linear Kernel Constant100
Maximum Laplacian Approximation Iterations105
Laplacian Approximation Threshold0.5
Misclassification Error Percentage8.33


Output 15.2.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 15.2.2: Evaluation History Plot

Evaluation History Plot


The plot in Output 15.2.3 displays how the best found objective value and the elapsed time changed with each iteration of the tuner.

Output 15.2.3: Iteration History Plot

Iteration History Plot


Last updated: August 06, 2026