How it works...
In this recipe, we standardized the variables of the Boston House Prices dataset by utilizing scikit-learn. To standardize these features, we needed to learn and store the mean and standard deviation for each variable by utilizing the train set. Then, we used those parameters to standardize the variables in the train and test sets. To do this, we used StandardScaler() from scikit-learn, which can learn and store these parameters in its attributes.
First, we loaded the dataset and divided it into train and test sets using the train_test_split() function from scikit-learn. We passed the independent variables as arguments. To do this, we dropped the target from the dataset with pandas' drop(). Next, we passed the target as a ...
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