Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7792305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:08:40+00:00 2026-06-01T22:08:40+00:00

When doing regression or classification, what is the correct (or better) way to preprocess

  • 0

When doing regression or classification, what is the correct (or better) way to preprocess the data?

  1. Normalize the data -> PCA -> training
  2. PCA -> normalize PCA output -> training
  3. Normalize the data -> PCA -> normalize PCA output -> training

Which of the above is more correct, or is the “standardized” way to preprocess the data? By “normalize” I mean either standardization, linear scaling or some other techniques.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:08:41+00:00Added an answer on June 1, 2026 at 10:08 pm

    You should normalize the data before doing PCA. For example, consider the following situation. I create a data set X with a known correlation matrix C:

    >> C = [1 0.5; 0.5 1];
    >> A = chol(rho);
    >> X = randn(100,2) * A;
    

    If I now perform PCA, I correctly find that the principal components (the rows of the weights vector) are oriented at an angle to the coordinate axes:

    >> wts=pca(X)
    wts =
        0.6659    0.7461
       -0.7461    0.6659
    

    If I now scale the first feature of the data set by 100, intuitively we think that the principal components shouldn’t change:

    >> Y = X;
    >> Y(:,1) = 100 * Y(:,1);
    

    However, we now find that the principal components are aligned with the coordinate axes:

    >> wts=pca(Y)
    wts =
        1.0000    0.0056
       -0.0056    1.0000
    

    To resolve this, there are two options. First, I could rescale the data:

    >> Ynorm = bsxfun(@rdivide,Y,std(Y))
    

    (The weird bsxfun notation is used to do vector-matrix arithmetic in Matlab – all I’m doing is subtracting the mean and dividing by the standard deviation of each feature).

    We now get sensible results from PCA:

    >> wts = pca(Ynorm)
    wts =
       -0.7125   -0.7016
        0.7016   -0.7125
    

    They’re slightly different to the PCA on the original data because we’ve now guaranteed that our features have unit standard deviation, which wasn’t the case originally.

    The other option is to perform PCA using the correlation matrix of the data, instead of the outer product:

    >> wts = pca(Y,'corr')
    wts =
        0.7071    0.7071
       -0.7071    0.7071
    

    In fact this is completely equivalent to standardizing the data by subtracting the mean and then dividing by the standard deviation. It’s just more convenient. In my opinion you should always do this unless you have a good reason not to (e.g. if you want to pick up differences in the variation of each feature).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code for doing a linear regression: data<-read.csv(File.csv,header=T) trans<-log(data) attach(trans) outdata<-summary(lm(Y~A
I am running a logistic regression in R and doing backward elimination inorder to
I am doing logistic regression in R. Can somebody clarify what is the differences
there are 3 regression bugs while doing a regression test for a software. local,unmasked
I am doing regression testing using NUnit, WatiN and VB.net. What i am doing
I am currently doing a lot of regression testing at my job. And like
doing a simple login for my website, which will hopefully keep the user logged
i have a problem doing the linear regression with three Matrix objects. m1 =
Doing some client-side JavaScript development, which requires me to call a client-side API which
Doing an ajax get request works as expected using the following code: $.ajax({ type:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.