September 2019
Intermediate to advanced
420 pages
10h 29m
English
An alternative to scaling features to zero mean and unit variance is to get features to lie between a given minimum and maximum value. Often, these values are zero and one, so that the maximum absolute value of each feature is scaled to unit size. In scikit-learn, this can be achieved using MinMaxScaler:
In [7]: min_max_scaler = preprocessing.MinMaxScaler()... X_min_max = min_max_scaler.fit_transform(X)... X_min_maxOut[7]: array([[ 0.33333333, 0. , 1. ], [ 1. , 0.66666667, 0.33333333], [ 0. , 1. , 0. ]])
By default, the data will be scaled to fall within 0 and 1. We can specify different ranges by passing a keyword argument, feature_range, to the MinMaxScaler constructor:
In [8]: min_max_scaler = preprocessing.MinMaxScaler(feature_range ...
Read now
Unlock full access