How it works...
In this recipe, we scaled the numerical variables of the Boston House Prices dataset that comes with scikit-learn to their minimum and maximum values. In order to learn and perpetuate these parameters, we used MinMaxScaler() from scikit-learn.
First, we loaded the dataset and divided it into train and test sets using the train_test_split() function from scikit-learn. To scale these features, we created an instance of MinMaxScaler() with its default parameters. Using the fit() method and by taking the train set as an argument, scaler learned each variable's maximum and minimum values, along with their differences, and stored these parameters in its data_max_, min_, and data_range attributes. With the transform() method, scaler ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access