Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

An Introduction To Categorical Data Analysis

Authors: Alan Agresti

2nd Edition

0470653205, 9780470653203

More Books

Students also viewed these Mathematics questions

Question

An improvement in the exchange of information in negotiations.

Answered: 1 week ago