5

Seems like a basic question, but I need to use feature scaling (take each feature value, subtract the mean then divide by the standard deviation) in my implementation of linear regression with gradient descent. After I'm finished, I'd like the weights and regression line rescaled to the original data. I'm only using one feature, plus the y-intercept term. How would I change the weights, after I get them using the scaled data, so that they apply to the original unscaled data?

Cartesian Theater
  • 1,920
  • 2
  • 29
  • 49

1 Answers1

6

Suppose your regression is y = W*x + b with x the scaled data, with the original data it is

y = W/std * x0 + b - u/std * W

where u and std are mean value and standard deviation of x0. Yet I don't think you need to transform back the data. Just use the same u and std to scale the new test data.

lennon310
  • 12,503
  • 11
  • 43
  • 61
  • @lennon310, sorry for troubling, but can you show me the intuitive on how above equation can unscale the data back? – Mohd Shahril Feb 28 '17 at 06:23
  • @lennon310 Could you please tell how it would work on new test data when using same u and std. – p.mathew13 Oct 30 '17 at 07:42
  • @p.mathew13 when you rescale coefficients back, you no longer need mu and std and just use unscaled data to get the prediction. – ptyshevs Dec 03 '19 at 15:32