# Normalize the whole dataset before modeling
from sklearn.preprocessing import StandardScaler
X = StandardScaler()\
.fit(X)\
.transform(X.astype(float))
# There are other normalization methods available like MinMaxScaler, Z-score etc
# Alternative approach
from sklearn.preprocessing import normalize
X = normalize(X.astype(float), norm="l1")
# Alternative approach
from sklearn.preprocessing import Normalizer
X = Normalizer()\
.fit(X)\
.transform(X.astype(float))
# Alternative approach with scipy : normalize to a standard deviation of 1
from scipy.cluster.vq import whiten
scaled_data = whiten(data) # Works with multi-dimensional data
# Normalizing without library
# Feature Scaling
df["feature_scaled"] = df["col"]/ (df["col"].max())
# Min-max Scaling
df["minmax_scaled"] = (df["col"] - df["col"].min()) / (df["col"].max() - df["col"].min())
# Z-score
df["z_scaled"] = (df["col"] - df["col"].mean()) / df["col"].std()