When feature scaling for a Multivariate Linear Regression housing predictor (housing area and # bedrooms), the exercise suggested "scale both types of inputs by their standard deviations and set their means to zero"

# MATLAB METHOD 1:

x = [ones(m, 1), x];
sigma = std(x);
mu = mean(x);
x(:,2) = (x(:,2) - mu(2))./ sigma(2);
x(:,3) = (x(:,3) - mu(3))./ sigma(3);


# MATLAB METHOD 2:

Why not simply scale inputs between zero and one? i.e. divide by the maximum:

x_range=max(x)
x(:,2) = (x(:,2)/x_range(2));
x(:,3) = (x(:,3)/x_range(3));


# METHOD 2 FEATURE PLOTS:

The exercise can be reproduced on MATLAB or OCTAVE:

# QUESTION

Is there a computational advantage with the first method over the second method?

• Although your question is a little unclear I tried to answer what I thought you were asking...labelling the plots is of importance, which plots belong to whom and also questions should be clear and asked at the end and not scattered in-between. – DuttaA Nov 21 '18 at 7:57

No, there is no computational advantage of the second method over the first, if you neglect the computational requirements for the calculation of $$\sigma$$ and $$\mu$$.

We generally use the first method for better results. This is because if you separate your dataset into train and test data, then you may normalise the train data perfectly between $$0$$ and $$1$$ by taking $$max$$ and $$min$$ from the train dataset. Your algorithm will only see data between $$0-1$$, but there is no way to ensure normalising the test data on the same $$max$$ and $$min$$ will result in the data being between $$0$$ and $$1$$..

So a better way is to use the Gaussian Distribution method, as the only assumption it makes is the data distribution is Gaussian which is just about true for any phenomenon (after some functional transformations which might be handled by the ML algorithm). I answered a similar question here.

• I can't cite any source for natural phenomenon being mostly gaussian, but if I remember accurately John tsitsiklis in one of his lecture mention the fact that most probability distribution follow gaussian PDF. – DuttaA Nov 21 '18 at 8:02
• The final sentence of the second paragraph is true. From the standpoint of performing gradient descent or employing normal equations to solve for the parameters, how is it a problem if the test data is not on the {0...1} interval? – gatorback Nov 27 '18 at 0:43
• @gatorback say you are using ML, and you have a term x^5....So if x=0.9 and 1.1 the values are 0.6 and 1.6 respectively...So your weights will not be prepared for such a surge for a small change..Whereas gaussian Probably regularize this by showing examples above 1....In NN the same thing Probably occurs. – DuttaA Nov 27 '18 at 9:13

Clarifications

Before directly answering the question, there are a few things to note.

• The word range is actually applicable to a dependent variable. On the input side, it is the domain that needs to be normalized.
• In the second method, since the minimum vector may not be the origin, the zeroth order term should be included in the normalization. The minimum must be subtracted from the maximum to determine the domain and must also be subtracted as an offset to the independent, pre-normalized values.
• The standard deviation is always less than half the difference between the max and min, so there is a difference in proportion between the two methods.

The crux of the question centers around the statistics of normalization and its potential impact on these methods.

• Multivariate linear regression (in the question introduction)
• Gradient descent (selected as a tag)

Although these two are not technically mutually exclusive, practically they are if by linear is meant conforming to $$\vec{y} = a \vec{x} + \vec{b}$$, where $$a$$ is a matrix dimensioned appropriately for $$\vec{x}$$ and $$\vec{y}$$. For that first degree polynomial cases, there is a closed form (formula) to acquire $$(\vec{a}, \vec{b}, c)$$ from a set of pairs $$(\vec{x}, \vec{y})$$, where $$c$$ is the correlation coefficient. It would be grossly wasteful to use iterative convergence methods, such as gradient descent, to calculate a mean squares regression result for a first degree polynomial model of the relation between $$\vec{x}$$ and $$\vec{y}$$.

If there is no closed form for the model or no known model at all, and the complexity of the function to be approximated is tenable in relation to the convergence methods available, the data available for training, and the computing resources and time that can be delegated to the task, then gradient descent is a method through which a least squares convergence on minimal loss may be possible.

The significance of artificial networks is that, through the interconnection of a sequence of layers, each with an array of like activation functions, a network can approximate a useful function the mathematical model of which is not explicitly known. Of the statistical functional approximation problems where no closed form is known and for which convergence methods are possible, artificial network training has become the appropriate device for a growing set of cases.

Normalization

The metrics of mean and standard deviation are designed specifically for data that can be approximated by a Gaussian distribution. The term normalization originated from the belief that the Gaussian distribution was normal, however Gauss did not hold that belief. He presented it as a distribution resulting from the limit of an accumulation of random perturbations as the mean of the square of the perturbation size decreases to zero as the length of the series of perturbations approaches infinity.

Because of this, if the loss (or error) function is a sum of the squares of difference between the current output values of an artificial network and the labels providing the accurate and correct values, a near Gaussian distribution of input is likely to produce a faster and complete convergence. In the multivariate case, there is an equivalent of the Gaussian distribution.

In the real world, data distribution very close to Gaussian is not the norm. The distribution of land surface temperatures at a specific latitude and longitude on earth for a particular month reflect two maxima in the temperature distribution, one for nighttime and one for daytime. The model of the relationship between these two maxima and the time of year, in chaos theory, are called attractors. Points seem attracted to those norms.

The distribution of signal amplitudes in common circuits and natural sounds in the air are not Gaussian distributed either, but the $$\log(P)$$ of the power of common signals and sounds are close to a Gaussian distribution, which is partly why decibels are a common measure of signal strength and loudness. The other part is that the logarithm in calculating decibels causes them to indicate relative geometric difference (ratio) in power rather than a less representative arithmatic difference.

Normalization is often oversimplified to mean ensuring values fall within a specific domain convenient to an algorithm's numerical representation or around a mean with a given standard deviation to feed a least squares strategy for statistical analysis or correlation. However, data is not often symmetric and nicely distributed.

In the case of land surface temperatures the nighttime distribution has a lower standard deviation than the daytime distribution, so the two peaks have different adjacent slopes in the distribution. How that is reflected in normalization varies depending on goals and algorithms receiving the normalized data. Normalization strategies for signal power and loudness would include running the data through a logarithm to reflect the near exponential Gaussian distribution of power values.

Outliers

Outliers are data points that fall outside an expected trend or relationship, either because they were incorrectly measured in one or more dimensions of measurement, the measurement was corrupted, they were strongly influenced by a phenomenon outside the intended range of study, or representative of a significant but previously undiscovered phenomenon. This last cause is why it is not wise to dismiss and exclude all outliers from functional analysis.

When outliers are valid data points that inconveniently lie more than a few standard deviations from mean, normalizing from zero to one causes a very narrow distribution peak in one place within that input domain. If the outlier is of the kind that should not be dismissed and legitimately representative of the phenomena under study or being controlled, then some normalization scheme other than simply a first degree polynomial translation of the data is indicated.

Housing Predictor

In the case of square footage of living space, the data is not symmetric. An increase of 10 square meters for a large house will not produce the same price differential as 10 square meter increase for a small one. A properly configured neural network may learn to perform something similar to a logarithm in the first few layers during training, or the engineer can explicitly perform a logarithm to un-skew the data and present it in a form with closer to a Gaussian distribution to the network for training and then also later for actual use.

At the exit, prior to presenting the network output to the loss function, applying an exponential function may also produce faster and more reliable convergence, since a monetary unit has different values to different buyers. A person buying a large house is less apt to be put off by cost associated with a fourth bedroom or more area than a person buying a small house.

Summary

The comparative advantages of different normalization methods are dependent upon a number of factors, including but not limited to these.

• The resolution of the data types used to represent forward and backward signal propagation in the network, which affects the conditions of signal saturation
• Skew of data set used for training
• The number of standard deviations to the min and max in the data set used for training
• Presence of multiple attractors in the distribution, which can occur in any of the features (dimensions of input) or combinations of them

Method one is best for a scenario that involves a Gaussian distribution and may be best for the housing prediction. Method two might be best if the distribution is relatively flat almost all the way to the extremes.

Running each method and comparing them may reveal advantages for one or the other that is not predicted in this answer and further knowledge can be gained about why by performing further experiments.