Question: > library(rpart) > dt=rpart(Species~.,iris) > plot(dt);text(dt); > table(predict(dt,type=class),iris$Species) Try these statements in R. Explain their meanings. Explain the result of the contingency table. > dt=rpart(Species~.,iris,control=rpart.control(cp=0.0,minsplit=0))
> library(rpart)
> dt=rpart(Species~.,iris)
> plot(dt);text(dt);
> table(predict(dt,type="class"),iris$Species)
Try these statements in R. Explain their meanings. Explain the result of the contingency table.
> dt=rpart(Species~.,iris,control=rpart.control(cp=0.0,minsplit=0))
> plot(dt);text(dt);
> table(predict(dt,type="class"),iris$Species)
Explain the meaning of the first statement. Explain the result of the contingency table and its difference with the previous result.
> train_index = c(sample(50,30), sample(50,30)+50, sample(50,30)+100)
> iris_train=iris[train_index,]
> iris_test=iris[-train_index,]
> dt=rpart(Species~.,iris_train)
> plot(dt);text(dt);
> table(predict(dt,newdata=iris_test,type="class"),iris_test$Species)
Explain the meaning of these statements.
> library(randomForest)
> rf=randomForest(Species~., iris, ntree=1000, proximity=TRUE)
> table(predict(rf,type="class"),iris$Species)
Explain the meaning of these statements.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
