How to do it...

To begin, we'll import the required packages, load the dataset, and prepare the train and test sets:

  1. Import the required Python packages, classes, and function:
import numpy as npimport pandas as pdfrom sklearn.datasets import load_bostonfrom sklearn.model_selection import train_test_splitfrom sklearn.preprocessing import Normalizer
  1. Let's load the Boston House Prices dataset from scikit-learn into a pandas dataframe:
boston_dataset = load_boston()data = pd.DataFrame(boston_dataset.data, columns=boston_dataset.feature_names)data['MEDV'] = boston_dataset.target
  1. Let's divide the data into train and test sets:
X_train, X_test, y_train, y_test = train_test_split( data.drop('MEDV', axis=1), data['MEDV'], test_size=0.3, random_state=0) ...

Get Python Feature Engineering Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.