Question: In this problem you are asked to build a sequence of regression trees using this data, to predict y from x1 and x2 , varying

 In this problem you are asked to build a sequence of
regression trees using this data, to predict y from x1 and x2

In this problem you are asked to build a sequence of regression trees using this data, to predict y from x1 and x2 , varying the tree depth. . Vary the maximum tree depth from 1 to 7 . Train each tree on a random set of 500 data points Test on the remaining 10000 - 500 data points Run 500 trials (train/test splits) for each depth. . Plot the MSE as a function of the maximum tree depth The cell below contains some starter code. You may modify this starter code in any way you wish. But be sure to keep the lines at the end, which plots the mean squared error on the test data versus the depth. trials = 500 tree_depth = np. arange (1, 8) test_mean_squared_error = np. zeros (len (tree_depth) ) from tadm import tadm for d in tadm (tree_depth) : rtree = DecisionTreeRegressor (max_depth=d) for trial in np. arange (trials) : fig = plt. figure () plt. plot (tree_depth, test_mean_squared_error) plt. xlabel (' tree depth' ) plt. ylabel (' MSE' )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!