It is very rare to find a raw dataset which perfectly follows certain specific distribution. Usually every dataset needs to be standarize by any means.
So this is the recipe on how we can standardise features in Python.
from sklearn import preprocessing import numpy as np
We have only imported numpy and preprocessing which is needed.
We have created an numpy array with different values.
x = np.array([[-500.5],
StandardScaler is used to remove the outliners and scale the data by making the mean of the data 0 and standard deviation as 1. So we are creating an object scaler to use standardScaler.
We have fitted the fit data and transformed train and test data form standard scaler. Finally we have printed the dataset.
scaler = preprocessing.StandardScaler()
standardized_x = scaler.fit_transform(x)
As an output we get
[[-500.5] [-100.1] [ 0. ] [ 100.1] [ 900.9]] [[-1.26687088] [-0.39316683] [-0.17474081] [ 0.0436852 ] [ 1.79109332]]