Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This code doesn't print graph as expacted , how can I fix it ? See athachedset.seed ( 6 5 2 2 0 4 8 )
This code doesn't print graph as expacted how can I fix it See athachedset.seed
library randomForest
# Root mean squared error
RMSE functionpred obs
returnsqrt sumpred obslengthpred
# checking
train
test
trees
for i in seqfrom to by
trees ctrees i
modelrf randomForesttarget age sex cp trestbps chol restecg exang ca data heartdata, ntree i
pred predictmodelrf newdatatrain.data, type'response'
rmsetrain RMSE pred train.data$target
train ctrain rmsetrain
pred predictmodelrf newdatatest.data, type'response'
rmsetest RMSE pred test.data$target
test ctest rmsetest
plottrees train,type lylimc col "red", xlab "Number of Trees", ylab "Root Mean Squared Error"
linestest type l col "blue"
legendtopright legend training set','testing set' col blue
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started