Question: 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

 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

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

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 Databases Questions!