Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Short Answer-Number Only; In assignment 2, we predict Purchase with all the other variables as predictors using the data OJ.csv. One tree model TreeOJ and

image text in transcribed

image text in transcribed

Short Answer-Number Only; In assignment 2, we predict Purchase with all the other variables as predictors using the data OJ.csv. One tree model TreeOJ and one Random forest model RFOJ have been developed respectively to fit this data set and their prediction performance have been evaluated. The following paragraph shows partial outputs from the two models: >dim(OJ) [1] 107018 > set.seed (10) > train = sample (nrow (OJ), nrow (OJ)0.8) > TreeoJ=tree (Purchase., OJ, subset = train) > cv.model=cv.tree (TreeoJ, K=10,FUN= prune. misclass) > cv.model \$size [1] 97421 $ dev [1] 176177170168326 $k [1] -Inf 0.0000004.3333339.500000160.000000 \$method [1] "misclass" attr (, "class") [1] "prune" "tree.sequence" > RFOJ=randomForest ( Purchase, , data =0J, subset=train, mt ry=4, importance=TRUE) > OJ.test = OJ [-train, ] > yhat.rf = predict (RFOJ, OJ.test, type="class") > Purchase. test=Purchase [-train] > yhat.rf = predict (RFOJ, oJ.test, type="class") > Purchase.test=Purchase [-train] > table (yhat.rf, Purchase.test) Purchase.test yhat.rf CHMM CH 11022 MM 1369 > RFOJ Call: randomForest (formula = Purchase , data = OJ, mtry =4, importance = TRUE, subset = train) Type of random forest: classification Number of trees: 500 No. of variables tried at each split: 4 OOB estimate of error rate: 20.098 Confusion matrix: CH MM class.error CH 456740.1396226 MM982280.3006135 Answer the following two questions based on the above paragraph of outputs. Please enter your answers in the box after each question. 1) Based on the ten-fold cross-validation error rate, what is the optimal size of TreeOJ? 2) What is the overall prediction accuracy of RFOJ? Show your answer as a number to three decimal places, e.g., 0.000 . Rounding if necessary

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

What is meant by planning or define planning?

Answered: 1 week ago

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago