This question already has an answer here:
Consider a matrix
X where the columns are the attributes and each row is an example. There is no order of occurrence of the examples. The target variables are continuous valued.
Does normalization to 0 mean and 1 standard deviation occur by considering the mean and standard deviation each column separately or for each row? Do we have a mean and sigma for each column? My confusion is that each feature is in a row representing and example. So feature normalization should be done for each example. But I may be wrong.
QUESTION 1) Should each row be normalized or each column wise? Is this the correct approach for calculating the mean and standard deviation for normalization (in MATLAB) and then apply it for normalization to zero mean and 1 std? I am calculating the mean and sigma for each attribute across all examples.
%X = data matrix rows are the number of examples, columns are the attributEs for i = 1:size(X, 2), mu(i) = mean(X(:,i)); sigma(i) = std(X(:,i)); end
X= [1 2 4; 1 1 1; 3 2 2; 0 0 0]; %4 examples and 3 attributes %for each column there is a mu and sigma mu = 1.2500 1.2500 1.7500 sigma = 1.2583 0.9574 1.7078
QUESTION 2) My dataset is composed of the input and targets (continuous valued). Should normalization of the entire dataset which contains the input and target be done altogether and then should the splitting of the normalized dataset into train, validation and test set and traintarget and test target be done?
Please correct me where wrong.