SMOTE Procedure

Example 35.2 Generating Out-of-Bound Synthetic Data

The iris data set contains sepal and petal dimensions for three different species of iris. This example demonstrates how to use the SMOTE procedure to apply the synthetic minority oversampling technique (SMOTE) to the iris data set and generate out-of-bound synthetic data for the interval columns. When you specify the EXTRAPOLATIONFACTOR= option in the SAMPLE statement, PROC SMOTE adds zero-mean Gaussian noise that is sampled from to the interval variables to perturb their boundaries, where is the EXTRAPOLATIONFACTOR= option value and is the standard deviation of the variable. The resulting synthetic generated data include extrapolated points that could exceed the minimum and maximum limits of the original data.

The following DATA step creates the input data table mylib.iris in your CAS session. These statements assume that your CAS engine libref is named mylib, as in the section Using CAS Sessions and CAS Engine Librefs, but you can substitute any appropriately defined CAS engine libref.

data mylib.iris;
    set sashelp.iris;
run;

The following statements run PROC SMOTE on the mylib.iris data table with an EXTRAPOLATIONFACTOR= option value of 0.8:

 proc smote data=mylib.iris seed=10;
     input sepallength sepalwidth/level=interval;
     input petallength petalwidth/level=interval;
     input species/level=nominal;
     output out=mylib.outExtrap;
     sample numSamples=150
            extrapolationfactor=0.8;
 run;

The interval and nominal input variables are specified by using the INPUT statements. In the SAMPLE statement, you specify the number of synthetic observations to generate in the NUMSAMPLES= option, and you specify the value of the oversampling boundary perturbation in the EXTRAPOLATIONFACTOR= option. The OUTPUT statement specifies the table to use for output results.

Output 35.2.1 shows the number of observations in the sample that are read and used for the analysis, as well as the number of samples that are generated.

Output 35.2.1: Number of Observations

The SMOTE Procedure

Number of Observations
Number of Observations Read150
Number of Observations Used150
Number of Synthetic Observations Generated150


Output 35.2.2 shows the settings for model training and output.

Output 35.2.2: Model Information

Model Information
Number of Synthetic Samples to Generate150
Number of Nearest Neighbors to Use in Calculation5
Seed Used for Random Number Generator10.0
Standard Deviation of the Gaussian Noise Used for Extrapolation0.8


To illustrate the effect of the EXTRAPOLATIONFACTOR= option on the generated samples, the preceding code is rerun with an EXTRAPOLATIONFACTOR= option value of 0. This disables extrapolation and stores the generated samples in a table named mylib.out.

The following DATA step merges the SepalLength variable from the original sashelp.iris data set and the generated samples with extrapolation (from the mylib.outExtrap table) and without extrapolation (from the mylib.out table). It prepares the data so that distributions and histograms of the SepalLength variable can be compared.

data  mylib.combined_data;
merge mylib.iris       (keep=SepalLength rename=(SepalLength=original))
      mylib.out        (keep=SepalLength rename=(SepalLength=synthetic))
      mylib.outExtrap  (keep=SepalLength rename=(SepalLength=syntheticExtrap));
run;

The following statements plot the distributions and histograms of the original mylib.iris data and the synthetic generated mylib.outextrapolate data by using an EXTRAPOLATIONFACTOR= option value of 0.8:

title "Overlaid Distributions of Original and Synthetic Data:
EXTRAPOLATIONFACTOR= Option Value of 0.8 ";
   proc sgplot data=mylib.combined_data;
      histogram original / binwidth=5 transparency=0.5
                  name="Original" legendlabel="Original";
      histogram syntheticExtrap / binwidth=5 transparency=0.5
                  name="Synthetic" legendlabel="Synthetic";
      density original / type=kernel lineattrs=GraphData1;
      density syntheticExtrap / type=kernel lineattrs=GraphData2;
      xaxis label="SepalLength";
      yaxis label="Percentage";
      keylegend "Original" "Synthetic" /
      across=1 position=TopRight location=Inside;
   run;

Output 35.2.3 illustrates the effect of the EXTRAPOLATIONFACTOR= option on the generated samples. By looking at the tails of the histogram plot, you can observe that the generated samples for the SepalLength variable contain out-of-bound and extrapolated values that the original data set does not contain.

Output 35.2.3: Sepal Length with EXTRAPOLATIONFACTOR= Option Value of 0.8

 Sepal Length with EXTRAPOLATIONFACTOR= Option Value of 0.8


Output 35.2.4 shows that when the extrapolation feature is disabled (that is, the EXTRAPOLATIONFACTOR= option value is 0), the synthetic generated samples for the SepalLength variable do not contain the out-of-bound values that the original data set contains.

Output 35.2.4: Sepal Length with EXTRAPOLATIONFACTOR= Option Value of 0

 Sepal Length with EXTRAPOLATIONFACTOR= Option Value of 0


Last updated: August 06, 2026