KPCA Procedure
Example 18.2 Denoising Concentric Circles
This example shows how to use the KPCA procedure to obtain the pre-image of the KPCA projection of the noisy concentric pattern. Because the KPCA projection along the first 10 eigendirections (PREIMAGE NPC=10) should contain the major part of the variance of the pattern, the pre-image of this projection in input space is expected to be much less noisy than the original pattern. The noisy pattern is generated using the same code as in Getting Started: KPCA Procedure, and the noisy concentric plot is shown in Figure 1.
In the example in the section Getting Started: KPCA Procedure, the Circles data are already loaded into the mylib library, so here you just call the KPCA procedure with the iterative pre-image method specified and then call the ASTORE procedure to find the pre-image of the noisy concentric pattern. The pre-image output is shown in Output 18.2.1.
/* First call PROC KPCA */
proc KPCA data=mylib.circles method=exact;
input x y;
kernel RBF/bw=0.3;
/* Use iterative pre-image method with 10 principal components */
preimage npc=10 method=iterative;
savestate rstore=mylib.state;
run;
/* Then use PROC ASTORE to calculate pre-image score,
here test and train are the same data sets */
proc astore;
/* scoring_mode=1 for pre-image scoring, default value is 0 for
projection on the principal components */
setoption SCORING_MODE 1;
setoption ITER_NPC 10;
setoption ITER_THRESH 1e-5;
setoption ITER_NUM 1000;
score data=mylib.circles rstore=mylib.state out=mylib.preimage_results
copyvars=(x y group);
run;
quit;
/* Plot the pre-image of the noisy concentric circles */
proc sgplot data=mylib.preimage_results;
styleattrs datasymbols=(Circle X);
scatter x=_pre_x y=_pre_y / group=group markerattrs=(size=5px);
yaxis min=-1.2 max=1.2;
xaxis min=-1.2 max=1.2;
run;
Output 18.2.1: Denoised Concentric Pattern

In Output 18.2.1, you can see that pre-image plot of the concentric pattern is indeed smoother (less noisy) than the original noisy concentric pattern.