Implementing maximum absolute scaling
Maximum absolute scaling scales the data to its maximum value – that is, it divides every observation by the maximum value of the variable:
As a result, the maximum value of each feature will be 1.0
. Note that maximum absolute scaling does not center the data, and hence, it’s suitable for scaling sparse data. In this recipe, we will implement maximum absolute scaling with scikit-learn.
Note
Scikit-learn recommends using this transformer on data that is centered at 0
or on sparse data.
Getting ready
Maximum absolute scaling was specifically designed to scale sparse data. Thus, we will use a bag-of-words dataset that contains sparse variables for the recipe. In this dataset, the variables are words, the observations are documents, and the values are the number of times each word appears in the document. Most entries in the data are 0
.
We will use a dataset consisting of a bag of words, which is available in the...