Let's first import the necessary Python libraries and get the dataset ready:
- Import the required Python libraries and classes:
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom sklearn.datasets import load_bostonfrom sklearn.model_selection import train_test_splitfrom sklearn.preprocessing import KBinsDiscretizerfrom feature_engine.discretisers import EqualWidthDiscretiser
- Let's load the predictor and target variables of the Boston House Prices dataset in a dataframe:
boston_dataset = load_boston()data = pd.DataFrame(boston_dataset.data, columns=boston_dataset.feature_names)data['MEDV'] = boston_dataset.target
The boundaries for the intervals should be learned using variables in the train set only, ...