from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaled_data = scaler.fit_transform(data)
# example of a standardization
from numpy import asarray
from sklearn.preprocessing import StandardScaler
# define data
data = asarray([[100, 0.001],
[8, 0.05],
[50, 0.005],
[88, 0.07],
[4, 0.1]])
print(data)
# define standard scaler
scaler = StandardScaler()
# transform data
scaled = scaler.fit_transform(data)
print(scaled)
from sklearn.preprocessing import StandardScaler
data = [[0, 0], [0, 0], [1, 1], [1, 1]]
scaler = StandardScaler()
print(scaler.mean_)
>>>[0.5 0.5]
print(scaler.transform(data))
>>>[[-1. -1.]
[-1. -1.]
[ 1. 1.]
[ 1. 1.]]
# Preprocessing allows us to standarsize our data
from sklearn import preprocessing
# define standard scaler
scaler = StandardScaler()
# transform data
scaled = scaler.fit_transform(data)