ENGR421 Homework 05- Decision Tree Regression Solved

24.99 $

Description

5/5 - (1 vote)

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 272 data points about the duration of the eruption and waiting time between eruptions for the Old Faithful geyser in Yellowstone National Park, Wyoming, USA (https://www.yellowstonepark.com/thingsto-do/about-old-faithful), in the file named hw05_data_set.csv.

2. Divide the data set into two parts by assigning the first 150 data points to the training set and the remaining 122 data points to the test set.

3. 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.

4. Learn a decision tree by setting the pre-pruning parameter 𝑃 to 25. Draw training data points, test data points, and your fit in the same figure. Your figure should be similar to the following figure.

5. 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 similar to the following sentences.
RMSE on training set is 4.541214189194451 when P is 25
RMSE on test set is 6.454083413352087 when P is 25
6. Learn decision trees by setting the pre-pruning parameter 𝑃 to 5, 10, 15, …, 50. Draw RMSE for training and test data points as a function of 𝑃. Your figure should be similar to the following figure.

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

  • hw5-zgsv39.zip