We'll begin by importing the required libraries, loading the dataset, and preparing the train and test sets:
- Import pandas and the required scikit-learn class and function:
import pandas as pdfrom sklearn.datasets import load_bostonfrom sklearn.model_selection import train_test_split
- 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
- 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)
- Let's learn the mean values from the ...