Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the Cars93 data set from the built-in package MASS available in R. You are to analyse the data using unsupervised learning. 1)Decision Trees. ****Any

Use the Cars93 data set from the built-in package "MASS" available in R.

You are to analyse the data using unsupervised learning.

1)Decision Trees.

****Any packages and functions referred to below are just suggestions. You can use different methods/packages/functions

Decision Trees (25%)

N.B. The tree( ) and cv.tree( ) functions are part of the "tree" library that is not supported in newer versions of r. Instead use the "rpart" library with the rpart( ) function as a replacement for the tree( ) function.

Other functions to use in rpart are printcp( ) and plotcp( ).

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 rpart( ) function with argument cp=-1 to make a full regression tree that can be used to predict the price of a car.

Use the summary( ) and printcp( ) functions to outline which variables are most useful in predicting Price.

Use the plotcp( ) function to decide where to prune this regression tree. You do not have to actually prune the tree.

Make another regression tree using the rpart( ) 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 gives 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.

make 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 printcp( ) function to outline which variables are useful to predict high or low MPG.city.

Use plotcp( ) to decide whether to prune this tree. You do not actually have to do the pruning.

make another classification tree using rpart( ), 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

8-cylinder car with 150 horsepower

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

Finite Math And Applied Calculus

Authors: Stefan Waner, Steven Costenoble

2nd Edition

0534366309, 9780534366308

More Books

Students also viewed these Mathematics questions

Question

6. How do histories influence the process of identity formation?

Answered: 1 week ago