Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note to tutor: Please assist me in responding to the question in the attached pic. The data preparation steps below are for context. Using R

Note to tutor:

Please assist me in responding to the question in the attached pic. The data preparation steps below are for context.

Using R

Preparing the data (20%)

Using Cars93

Move "Model" to column1. One way is to use the dplyr library from the tidyverse package.

Let the model names be your rownames (not to be used as data, but will be the name of each row). See James textbook, page 55 for some guidance.

XX Ensure that the data is complete before doing the analysis. Look for "NA" entries, especially in the "Rear.seat.room" and "Luggage.room" columns. You may choose to replace "NA" with 0.

Look at the spelling of "Chrysler" as you go down the column. Fix the error.

"Cylinders" has a non-numeric term. Make an appropriate decision.

If necessary, replace qualitative data with quantitative data.

For binary data, e.g. Origin: USAon-USA can be coded 1 or 0. Do you need two columns, or one? You can use the dummy( ) function from the dummies package.

For nominal or ordinal data, egDriveTrain, you can use 3 sets of binary data columns: Front : 1 or 0, Rear: 1 or 0, and 4WD: 1 or 0. You can use the dummy_cols( ) function in the fastDummies package.

Remove the original columns of categorical/binary data if dummies have been substituted.

You can remove columns of data that you think are unnecessary, but you must justify that decision

image text in transcribed
> 8-cylinder car with 150 horsepower Decision Trees (25%) . N.B. The tree( ) and sxtree( ) functions are part of the "tree" library that is not supported in newer versions of r. Instead use the "react" library with the react! } function as a replacement for the tree( ) function. . Other functions to use in pract are printcal ) and RARER( )- Regression Tree (Predicting Price) . Use the original data with a mix of quantitative and qualitative data (after spelling errors and N/A are fixed, of course) Remove the "Make" column and let the "Model" column be your rownames You should remove the columns "Min Price" and "Max Price" from the data as they will surely be influencing Price, and you want to know which other features are seen to be useful predictors of Price. Use a set seed( ) function to allow replication of your sample of training data. . Separate the data: Use 60 random rows as training data, and the remaining 33 as test data. Use the react[ ) function with argument cp=-1 to create a full regression tree that can be used to predict the price of a car. Use the summary! ) and printco( ) functions to outline which variables are most useful in predicting Price. Use the plotcol ) function to decide where to prune this regression tree. You do not have to actually prune the tree. Create another regression tree using the practi function, but this time do not include cp=-1. Compare this tree with your above decision on pruning. Predict the price of the following cars: A Honda with 22 MPG city, weight 2500, and Horsepower 95. A Dodge with 19 MPG city, weight 2400, and Horsepower 90. A Mazda with 25 MPG city, weight 2800, and Horsepower 100. Classification Tree (Classifying as High or Low MPG City) Remove the RX-7 row from the data (it has the only "rotary" under cylinders, and its removal ives opportunity for equal numbers of training and test data). Use a seed to randomise and create two sets of equal data: for training and test. Create another tree, this time to classify cars as Low City-MPG and High City-MPG, with a Low City-MPG being less than 20.5. Use rpart! ) with splitting method: gini and the argument cp = -1 for a full tree Use the printer! ) function to outline which variables are useful to predict high or low MRG FITX Use plotcp!) to decide whether to prune this tree. You do not actually have to do the pruning. Create another classification tree using poact( ), but this time do not include cp = -1. . Plot and compare this tree with your decision on pruning Using your pruned tree, determine the City MPG classification for a: > 4-cylinder car with 4 Passengers >6-cylinder car from BMW

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

Mathematics Concepts With Applications

Authors: Charles P McKeague

1st Edition

1630983136, 9781630983130

More Books

Students also viewed these Mathematics questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago