The SVDD Procedure

Getting Started: SVDD 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 demonstrates how you can use the SVDD procedure to obtain a description of two-variable data and perform outlier detection. The training data in this example are refrigerant analysis data (Heckert and Filliben 2000). The data table contains 360 observations and 31 variables. The variables represent various process measurements that are taken during the refrigerant analysis. This example uses variables y5 (inlet water temperature 1) and y4 (pressure drop 6) to perform an SVDD training. Variables y4 and y5 are selected to highlight the ability of the SVDD algorithm to obtain an accurate description of the training data.

The following DATA step creates the refrigerant (which is stored in the Work library by default):

	data refrigerant;
	   infile datalines delimiter=',';
	   input y4 y5 ;
	   label y4="Pressure Drop 6" y5="Inlet Water Temperature 1";
	   datalines;
	2.0562,25.0904
	2.04147,25.1676
	2.04922,25.6362

   ... more lines ...   

The following code standardizes variables y4 and y5:

 proc sql noprint;
    select min(y4), min(y5), max(y4), max(y5)
    into :miny4, :miny5, :maxy4, :maxy5
    from  Refrigerant;
 quit;

data refrigerant;
   set refrigerant;
   y4=(y4-&miny4)/%sysevalf(&maxy4-&miny4);
   y5=(y5-&miny5)/%sysevalf(&maxy5-&miny5);
run;

The following statements plot inlet water temperature 1 against pressure drop 6:

 proc sgplot data=Refrigerant;
    title "Refrigerant Analysis";
    title1 "Scatter plot of inlet water temperature against pressure drop";
    scatter x=y4 y=y5/markerattrs=(size=3 symbol=circlefilled);
 run;

Figure 1 shows the results. The scatter plot indicates four distinct clusters.

Figure 1: Scatter Plot of Inlet Water Temperature against Pressure Drop

Scatter Plot of Inlet Water Temperature against Pressure Drop


You can load the work.refrigerant data set into your CAS session by specifying your CAS engine libref in the second statement in the following DATA step:

data mycas.refrigerant;
   set refrigerant;
run;

These statements assume that your CAS engine libref is named mycas, as in the section Using CAS Sessions and CAS Engine Librefs, but you can substitute any appropriately defined CAS engine libref.

The following statements execute the SVDD algorithm on the mycas.refrigerant data table and produce Figure 2 through Figure 5.

 proc svdd data=mycas.Refrigerant;
    id y4 y5;
    input y4 y5/level=interval;
    kernel rbf / bw=0.021;
    savestate rstore=mycas.state;
 run;

The INPUT statement defines the input variables y4 and y5 as interval variables. The KERNEL statement specifies the kernel function as a radial basis function (RBF) and specifies a value of 0.021 for the bandwidth parameter. The SAVESTATE statement creates an analytic store for the model and saves it as a binary object in the mycas.state data table. You can use the analytic store later in the ASTORE procedure to score new data. The "Model Information" table in Figure 2 summarizes the key options and the input data variables.

Figure 2: Refrigerant Analysis Model Information

Model Information
Optimization MethodActive Set
Kernel TypeRBF
RBF Kernel Bandwidth0.021
Bandwidth Selection MethodUser specified
Bandwidth Relative Scale0.1663083933
Expected Outlier Fraction1E-6
Optimization Tolerance0.0001
Number of Interval Variables2
Number of Nominal Variables0


The "Training Results" table in Figure 3 shows the number of support vectors and the upper R squared threshold value.

Figure 3: Refrigerant Analysis Training Results

Training Results
Number of Support Vectors38
Number of Support Vectors on Boundary38
Number of Dropped Observations0
Threshold R Square Value0.94341
Constant (C_r) Value0.05659
Run Time (seconds)0.00698


Figure 4 displays the number of observations in the training data set.

Figure 4: Refrigerant Analysis Training Observations

Number of Observations Read360
Number of Observations Used360


The "Optimization Summary" table in Figure 5 shows whether the solution is optimal, the number of iterations that were required, and the objective function value.

Figure 5: Refrigerant Analysis Optimization Summary

Optimization Summary
Number of Iterations1
Objective Value0.0565942724
Infeasibility0.0000295791
Optimization StatusOptimal
DegenerateNo


To evaluate the quality of the training results, scoring is performed on a 200 times 200 data grid. The following DATA step creates a data set named scoreds to contain the scoring observations:

data scoreds;
   do i=0 to 1 by 0.005;
      do  j=0 to 1 by 0.005;
         output;
      end;
   end;
rename i=y5 j=y4;
run;

You can load the scoreds data set into your CAS session by specifying your CAS engine libref in the second statement in the following DATA step:

data mycas.scoreds;
   set scoreds;
run;

The following code scores the mycas.scoreds data by using the score analytic store that was created during training:


 proc astore;
    score data=mycas.scoreds
    out=mycas.score_results
    rstore=mycas.state;
 quit;

The following code copies the score_results into the Work library:

data work.score_results;
   set mycas.score_results;
run;

The following code plots the scoring results:

 proc sgplot data=score_results(where=(_svddscore_ in (-1,1)));
 styleattrs datacontrastcolors=(ligr black) datasymbols=(circlefilled);
 title "Refrigerant Analysis";
 title1 "Scatter plot of inlet water temperature against pressure drop";
 title2 "Scoring Results";
 scatter x=y4 y=y5/group=_svddscore_ markerattrs=(size=3);
 run;

Figure 6 shows the scatter plot of the scoring data set. The gray area indicates the observations that are identified as outliers, and the black area indicates observations that are identified as inliers. Comparison between Figure 1 and the training data in Figure 6 indicates that SVDD has correctly identified observations outside the training data as outliers. In this example, the SVDD procedure described four disjoint clusters. Any observation not part of these four clusters was identified as an outlier during scoring. This example illustrates that SVDD procedure can be used to describe data with multiple disjoint clusters, without the need to specify the correct number of clusters in advance. The scoring results in Figure 6 indicate that the description obtained using SVDD takes essential geometric features of the training data into account. The scoring correctly identified any observations with pressure drop 6 and inlet water temperature 1 values different from the training data values correctly identified as outliers.

Figure 6: Scoring Results Scatter Plot

Scoring Results Scatter Plot


Last updated: November 11, 2020