Feature Normalization in MATLAB

X_norm = X;
mu = zeros(1, size(X, 2));
sigma = zeros(1, size(X, 2));
for i = 1:2
    mu(1,i) = mean(X,(:,i));
    sigma(1,i) = std(X,0,(:,i));
    col_mu = ones(size(X,1), 1) * mu(:,i)
    X_norm(:,i) = X(:,i) - col_mu
    X_norm(:,i) = X(:,i) * (1/sigma(1,i))
end
end

I am trying to implement feature normalization as part of the Stanford Coursera ML Course. When I run this, I get an error message "invalid use of operator" for line 13, column 23.

The one that says (mu(1,i) = mean...

I was trying to make the i-th column of mu the mean of the i-th column of X. What am I doing wrong?



Read more here: https://stackoverflow.com/questions/66280278/feature-normalization-in-matlab

Content Attribution

This content was originally published by dgoodie at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: