Home Decision Tree Regression
Post
Cancel

Decision Tree Regression

What is decision tree regression?

The entire data set (parent node) is divided into two data sets (child nodes) based on the reference value. Repeat the above steps for each child node to create child nodes until only one class of data exists in the child node.

There are example images below that show step by step how nodes are made.

Step 1



The data set is scattered across a graph with axes X1 and X2.



Step 2



Make a split 1 by reference value(X1 < 20)






Step 3



Make a split 2 by reference value(X2 < 170)






Step 4



Make a split 3 by reference value(X2 < 170)






Step 5



Make a split 4 by reference value(X1 < 40)






Example



Code



1
2
3
4
from sklearn.tree import DecisionTreeRegressor
regressor = DecisionTreeRegressor(random_state=0)
regressor.fit(X, y)
X_pred = regressor.predict(X)



Result







You can see my implementation on my GitHub

This post is licensed under CC BY 4.0 by the author.