Why do we normalize the whole dataset, vs individual features?

The assignment does normalization using the following code:

X_multi_norm = (X_multi - np.mean(X_multi))/np.std(X_multi)
Y_multi_norm = (Y_multi - np.mean(Y_multi))/np.std(Y_multi)

Why are we normalizing the values with respect to the mean of the whole dataset, as opposed to values in individual columns? For instance, GrLivArea and OverallQual have different units of measurement, so shouldn’t we normalize these rows ‘individually’? Or is np.mean/np.std already doing this for us?

1 Like

Yes. The means are computed for each feature.
For example, np.mean(X_multi) returns a vector which holds the mean for each feature.

1 Like

To illustrate:

np.mean(X_multi) gives a vector of two values - one for each feature.

Awesome! makes sense. Is this something specific to operations on Pandas Dataframes? According to numpy.mean — NumPy v1.26 Manual, if an axis is not specified it will attempt to take the mean of the flattened array.

The course uses Numpy version 1.20.1. That’s what the Coursera Labs platform provides.

I’m not sure exactly how it’s documented, it may have to do with the default behavior of the keepdims parameter. Don’t really know.

An experiment is often more useful than the documentation.