베이지안

hottogi·2022년 11월 11일
0
library(e1071)
data <- read.csv(file = "heart.csv", header = T)
head(data)
str(data)
library(caret)
set.seed(1234)
tr_data <- createDataPartition(y=data$AHD, p=0.7, list=FALSE)
tr <- data[tr_data,]
te <- data[-tr_data,]
Bayes <- naiveBayes(AHD~. ,data=tr)
Bayes

predicted <- predict(Bayes, te, type="class")
table(predicted, te$AHD) 
AHD <- as.factor(te$AHD)
confusionMatrix(predicted, AHD)
profile

0개의 댓글