I am trying to implement a neural network that predicts the stock market in python. In input I have a 2d numpy array and I want to normalize the data. I tried with this code but I don't this this is the best choice for this type of task.
def normData(data):
#data_scaled = preprocessing.scale(data)
data = scale( data, axis=0, with_mean=True, with_std=True, copy=True )
return data
Do you know any other kind of normalization process that could better fit this task and its python implementation? Thank you
UPDATE: Now before the normalization I transfrom the ndarray to list, but printing
print data.mean(axis=0)
the mean is way far from 0. Its something like 4. Any ideas?
I personally would use scikit-learn's standard scalar module. It allows you to pick the mean and standard deviation that you want and is very fast.
from sklearn.preprocessing import StandardScaler
# Load data and split into testing and training data
scale = StandardScaler(with_mean=0, with_std=1)
scale.fit(training_data, training_label)
new_training_data = scale.transform(training_data)
new_testing_data = scale.transform(testing_data)
A link to the documentation:
http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With