What is the meaning of Standardization in KNN

knn
machine_learning
data_wrangling
data_science

#1

I have lot of confusion in the standardization process in the K-NN algorithm.
Here is the code:-

from sklearn.preprocessing import StandardScaler
scaler= StandardScaler()
scaler.fit(df.drop(‘TARGET CLASS’,axis=1))
scaled_features=scaler.transform(df.drop(‘TARGET CLASS’,axis=1))


#2

The idea behind StandardScaler implementation is to transform your data such that corresponding distribution will have a mean value 0 and standard deviation of 1. Given the distribution of your data, each value in the dataset will have the sample mean value subtracted, and then divided by the standard deviation of entire dataset.