Hi, I need to do a ConfusionMatrix in Random Forest. This is my code, how can I do it?
library(randomForestExplainer)
library(randomForest)
iris[1,]
unique(iris$Species)
table(iris$Species)
db_class <- iris
plot(db_class, col=as.factor(db_class$Species))
righe_train <- sample(nrow(db_class), nrow(db_class)*0.8)
db_class_dc_train <- db_class[righe_train,]
db_class_dc_test <- db_class[-righe_train,]
plot(db_class [,-ncol(db_class)], col=as.factor(db_class$Species))
model_rf <- randomForest(Species~.,
db_class_dc_train,
ntree = 10)
varImpPlot(model_rf)
plot_min_depth_distribution(model_rf)
getTree(model_rf, 10, labelVar = TRUE)
model_rf$err.rate
measure_importance(model_rf)
pred_rf_test <- predict(model_rf, db_class_dc_test, type = "class")
CrossTable(x=db_class_dc_test$Species, y=pred_rf_test, prop.chisq = TRUE)