I am trying to perform feature scaling on the values in an array. Given array X, I want to scalar subtract the mean of each column from the value of each element, and then divide each elements by the column's standard deviation. Is there any way to do this without iterating over each value? This is my attempt:
import numpy as np
X_norm = X;
mu = np.zeros(len(X[:,0]))
sigma = np.zeros(len(X[:,0]))
for i in range(len(mu)):
mu[i] = np.mean(X[i,:])
sigma[i] = np.std(X[i,:])
X_norm[i,:] = (X_norm[i,:] - mu[i])/sigma(i)
I receive
TypeError: 'numpy.ndarray' object is not callable
when I try to run it.
Aucun commentaire:
Enregistrer un commentaire