Starting from:

$34.99

ENGR 421 / DASC 521 Homework 05-Decision Tree Regression Solution



In this homework, you will implement a decision tree regression algorithm in Python. Here are the steps you need to follow:

1. You are given a univariate regression data set, which contains 180 training data points in the file named hw05_data_set_train.csv and 180 test data points in the file named hw05_data_set_test.csv.

2. Implement a decision tree regression algorithm using the following pre-pruning rule: If a node has 𝑃 or fewer data points, convert this node into a terminal node and do not split further, where 𝑃 is a user-defined parameter. (40 points)

3. Learn a decision tree by setting the pre-pruning parameter 𝑃 to 30. Draw training data points/test data points, and your fit in the same figures. Your figure should be like the following figures. (20 points)


4. Calculate the root mean squared error for training and test data points. The formula for
RMSE can be written as
RMSE = ’ RMSE = ’ .
’$%&!’ ’$*+$
Your output should be like the following sentences. (20 points)

RMSE on training set is 0.2881929342801884 when P is 30
RMSE on test set is 0.22542236010134897 when P is 30
5. Learn decision trees by setting the pre-pruning parameter 𝑃 to 10, 15, …, 50. Draw RMSE for training and test data points as a function of 𝑃. Your figure should be like the following figure. (20 points)

What to submit: You need to submit your source code in a single file (.py file) named as STUDENTID.py, where STUDENTID should be replaced with your 7-digit student number.
How to submit: Submit the file you created to Blackboard. Please follow the exact style mentioned and do not send a file named as STUDENTID.py. Submissions that do not follow these guidelines will not be graded.
Cheating policy: Very similar submissions will not be graded.

More products