BookmarkSubscribeRSS Feed
satgrgfq4tr4fds
Calcite | Level 5

I’m doing PCA on a training dataset before training a predictive model and I'm using 3 PC’s that explains about 97% of the data. Now, how can I do PCA transformation on test data? I will probably have to use eigen vector matrix(or rotation matrix) obtained from the PCA results of the train dataset and perform matrix multiplication with test data. Do I have to scale and center the test data before? Or is there a function in SAS that does this operation? If you are familiar with R, it will be equivalent to using predict() function with prcomp object.

 

 

1 REPLY 1
PaigeMiller
Diamond | Level 26

I can't specifically answer Viya questions ... however, I can answer PCA questions. When you perform PCA on a training data set, the exact same scaling must be used on the test data set. If the mean of X1 is 14 in the training data set and the standard deviation of X1 is 2.7 in the training data set, then these values must be used to scale the test data X1 as well.

 

Also, please note: The method of using PCA before a predictive model isn't optimal. PCA can find vectors that are not very predictive. If you use Partial Least Squares analysis, this produces "PCA-like" vectors that designed to be predictive of whatever Y variable(s) you have, as predictability is the criterion that PLS optimizes.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 501 views
  • 0 likes
  • 2 in conversation