Академический Документы
Профессиональный Документы
Культура Документы
rm(list=ls())
library(readr)
str(Data)
set.seed(123)
true
pred acc good unacc vgood
acc 111 4 15 6
good 4 10 1 0
unacc 2 0 341 0
vgood 2 3 0 16
Pruning implementation.
printcp(data_model )
opt<-which.min(data_model $cptable[,"xerror"])
cp <- data_model $cptable[opt,'CP']
Pruned_data_model <- prune(data_model ,cp)
plot(Pruned_data_model )
text(Pruned_data_model )
Random Forest
Loading library and building data_model .
library(randomForest)
set.seed(100)
rf<- randomForest(Class~.,data=train1)
rf
Call:
randomForest(formula = Class ~ ., data = train1)
Type of random forest: classification
Number of trees: 500
No. of variables tried at each Data_splitt: 2
Reference
Prediction acc good unacc vgood
acc 116 4 8 6
good 2 11 1 0
unacc 0 0 348 0
vgood 1 2 0 16
Overall Statistics
Accuracy : 0.9534
95% CI : (0.9315, 0.9699)
No Information Rate : 0.6932
P-Value [Acc > NIR] : < 2.2e-16
Kappa : 0.9006
Mcnemar's Test P-Value : NA
Statistics by Class:
Plot
No of tress vs error.
Reference
Prediction acc good unacc vgood
acc 109 0 8 0
good 3 15 2 0
unacc 3 0 347 0
vgood 4 2 0 22
Overall Statistics
Accuracy : 0.9573
95% CI : (0.936, 0.973)
No Information Rate : 0.6932
P-Value [Acc > NIR] : < 2.2e-16
Kappa : 0.9096
Mcnemar's Test P-Value : NA
Statistics by Class: