Scaling to the maximum and minimum values
Scaling to the minimum and maximum values squeezes the values of the variables between 0 and 1. To implement this scaling technique, we subtract the minimum value from all the observations and divide the result by the value range, that is, the difference between the maximum and minimum values:
In this recipe, we will implement scaling to the minimum and maximum values by utilizing scikit-learn.
How to do it...
To begin, we will import the required packages, load the dataset, and prepare the train and test sets:
- Import pandas and the required scikit-learn classes and functions:
import pandas as pd from sklearn.datasets import fetch_california_housing from sklearn.model_selection import train_test_split from sklearn.preprocessing import MinMaxScaler
- Let’s load the California housing dataset from scikit-learn into a pandas dataframe:
X, y = fetch_california_housing( &...