GPREG Procedure

Getting Started: GPREG Procedure

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.

This example uses the Sinewave data set to demonstrate how you can use the GPREG procedure to perform Gaussian process regression analysis and save the trained model in an analytic store. The Sinewave data set contains 1,000 noisy samples from a two-dimensional sine wave function; it has two variables, x and y.

The following DATA steps generate the Sinewave data set and upload it to your session:


data Sinewave;
   keep x y;
   call streaminit(123);       /* set random number seed */
   do i = 1 to 1000;
      u = rand("Uniform");
      x = u;
      y = sin(6*x)+rand("Normal", 0, 0.01);
      output;
   end;
run;

data mylib.sinewave;
   set Sinewave;
run;

The second DATA step assumes that your libref is named mylib, but you can substitute any appropriately named libref.

The following statements use PROC GPREG to perform Gaussian process regression on the data and save the data in an analytic store:

proc gpreg
   data=mylib.sinewave
   seed=12345
   nThreads=32
   nInducingPoints=10
   fixInducingPoints
   outInducingPoints=mylib.gpreg_ip
   outVariationalCov=mylib.gpreg_cov;
   target y/level=interval;
   input x;
   partition fraction(valid=0 test=0.2 seed=1235);
   kernel rbf(
      autoRelevanceDetermination
      fixKernelParmFirstIter
      jitterMaxIters=10
      );
   optimization adam(
      regl1=0.5
      maxiters=500
      learningRate=0.05
      momentum=0.8
      adaptiveRate
      adaptiveDecay=0.9
      printfreq=200
   );
    savestate rstore=mylib.astore;
    output out=mylib.score copyvars=(x y);
    display nObs varStats modelInfo ParameterEstimates;
run;

These statements assume that your libref is named mylib, but you can substitute any appropriately defined libref.

PROC GPREG generates four ODS tables, which are shown in Figure 1 through Figure 4.

Figure 1: Number of Observations

The GPREG Procedure

Number of Observations
Number of Observations Read1000
Number of Observations Used1000
Number of Observations Used for Training815
Number of Observations Used for Testing185


Figure 2: Variable Statistics

The GPREG Procedure

Input Variable Statistics
VariableMeanStandard
Deviation
x0.5117670.284632
y-0.0206740.724311


Figure 3: Model Information

Model Information
Seed for Random Initialization for Clustering and Optimization Parameters12345
Number of inducing points10
Kernel TypeRBF
Automatic Relevance DeterminationTRUE
Fix Kernel Parameters in the First IterationFALSE
Fix Inducing Points in OptimizationTRUE
Use Simple InitializationTRUE
Maximum Number of Iterations for Jitter Cholesky Decomposition10


Figure 4: Number of Observations

Parameter Estimates
Parameter TypeParameter NameParameter Value
KernelVariance323.367996
KernelInverse square of length scale for variable x735.930478
NoiseVariance328.349708


In this example, PROC GPREG generates the score output table mylib.score. The following statements print the first 15 rows of the table, which is shown in Figure 5. The value 1 in the _ROLE_ column means that the observation has a training role, and the value 3 in the _ROLE_ column means that the observation has a testing role.

proc print noobs data=mylib.score (obs=15);
run;

Figure 5: Score Output Table

xyP_yP_yMEANP_ySTD_WARN__ROLE_
0.58170-0.35197-0.019638-0.01963813.6534 1
0.361590.81021-0.020507-0.02050713.0249 1
0.337590.882970.0022920.00229213.8129 1
0.97680-0.41130-0.020674-0.02067413.0249 1
0.75099-0.96933-0.021611-0.02161113.0845 1
0.81052-0.99303-0.020674-0.02067413.0249 1
0.018000.10657-0.018723-0.01872314.1779 1
0.105030.59752-0.015572-0.01557213.1166 1
0.077300.43982-0.034881-0.03488115.1158 1
0.73482-0.94985-0.026007-0.02600714.8356 1
0.92549-0.65055-0.021292-0.02129213.0015 1
0.92680-0.65987-0.021171-0.02117113.0097 3
0.459900.38082-0.015619-0.01561913.0897 1
0.99078-0.33322-0.020674-0.02067413.0249 1
0.62949-0.60994-0.020674-0.02067413.0249 1


Last updated: September 23, 2026