# Estimate accuracy using the bootstrap.
intall.packages("caret")

# load the library
library(caret)

# importar datos
# load the iris dataset
data(iris)
data <- iris

# Particiones 70-30
# define an 70%/30% train/test split of the dataset
split=0.70
trainIndex <- createDataPartition(data$Species, p=split, list=FALSE)
data_train <- data[ trainIndex,]
data_test  <- data[-trainIndex,]


# define training control
train_control <- trainControl(method="boot", number=100)
# train the model
model <- train(Species~., data=data_train, trControl=train_control, method="nb")
# summarize results
print(model)
summary(model)

# make predictions
predictions <- predict(model, data_test[,1:4]) 

# summarize results
confusionMatrix(predictions, data_test$Species)
