Machine Learning 7 : Feature Scaling
FEATURE SCALING
Feature scaling is a method used to standardize the range of independent variables or features of data (data normalization). Why? Because the majority of classifiers calculate the distance between two points by the Euclidean distance. If one of the features has a broad range of values, the distance will be governed by this particular feature. Therefore, the range of all features should be normalized so that each feature contributes approximately proportionately to the final distance.
Rescaling:
Rescaling is the method to scaling the range of features to a scale that range in [0, 1].
X’ = X - Xmin/ Xmax - Xmin
|
Xmin minimum value in the data
Xmax maximum value in the data
|
Sklearn:
from sklearn.preprocessing import MinMaxScaler
weights = numpy.array ([115.0], [140.0], [175.0])
scaler = MinMaxScaler()
rescaled_weight = scaler .fit_transform(weights)
0 commenti