Decision Tree Regression

Preliminaries

Load Boston Housing Dataset

# Load data with only two featuresboston=datasets.load_boston()X=boston.data[:,0:2]y=boston.target

Create Decision Tree

Decision tree regression works similar to decision tree classification, however instead of reducing Gini impurity or entropy, potential splits are measured on how much they reduce the mean squared error (MSE):

$$\text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2$$

where $y_i$ is the true value of the target and $\hat{y}_i$ is the predicted value.