I saw on Coursera machine learning classes that is possible to normalize data in two ways:

data = (data - mean) / max(data) - min(data)

or you can use an Octave function called std(), it does the following:

data = (data - mean) / std(data)

Which normalization is better to normalize a matrix containing house size(20 m² to 1000 m²), number of rooms(2 to 20) and the house's prices(10000 to 15000000)? And why its is better? I'm using linear regression to predict a house price, with size and number of rooms as parameters. Although, then a try to plot it using plot function in Octave, but it gives an error saying that the values are too high. So, if I normalize my data using both approaches I can plot it. So, which is better and I? When I should use std() or the other approach?

  • 3
    $\begingroup$ Could you explain why you want to "normalize" this matrix? What are you going to do with the matrix that you think requires some such operation? $\endgroup$
    – whuber
    Mar 18, 2016 at 18:53
  • 1
    $\begingroup$ You need extra () in your first equation. $\endgroup$
    – Nick Cox
    Mar 18, 2016 at 19:35
  • 2
    $\begingroup$ std() in your notation doesn't change the data; it just calculates a summary measure. The first operation, in the usual interpretation of the equation, just changes the scale and flushes out the units of measurement. Otherwise it does nothing fundamental to affect any regression. $\endgroup$
    – Nick Cox
    Mar 18, 2016 at 19:37
  • $\begingroup$ I'm sorry, I edited my question. Now std() does something to the data. $\endgroup$
    – Pasdf
    Mar 19, 2016 at 2:30
  • $\begingroup$ I agree with Nick Cox. The purpose of normalization before using linear regression is to make the ranges of two data set(size and number of rooms) similar. For this purpose, the first normalization guarantees that, while the second doesn't. $\endgroup$
    – hopflink
    Mar 19, 2016 at 3:16


Browse other questions tagged or ask your own question.