tylerdurdenX
tylerdurdenX

Reputation: 21

Prediction in R using Bayesian

I want to find the class value for ali(öksürük=var,ateş=yok,halsizlik=var) using bayesian classification. The code below is working but I get

Warning messages:

1: naive_bayes(): Feature Öksürük - zero probabilities are present. Consider Laplace smoothing.

2: naive_bayes(): Feature Ateş - zero probabilities are present. Consider Laplace smoothing.

3: naive_bayes(): Feature Halsizlik - zero probabilities are present. Consider Laplace smoothing.

Öksürük<-c("Var","Yok","Yok","Yok","Var","Yok","Yok","Yok","Var","Yok","Var")
Ateş<-c("Var","Var","Yok","Yok","Yok","Var","Yok","Var","Var","Var","Yok")
Halsizlik<-c("Yok","Var","Yok","Var","Yok","Yok","Var","Var","Yok","Var","Var")
COVID19<-c("POZİTİF","POZİTİF","POZİTİF","POZİTİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","")
df<-data.frame("Öksürük"=Öksürük,"Ateş"=Ateş,"Halsizlik"=Halsizlik,"COVID-19"=COVID19)     
nbfit<-naivebayes::naive_bayes(df[1:10,1:3],df[1:10,4])
ali<-predict(nbfit,df[11,1:3])

Upvotes: 0

Views: 226

Answers (1)

Michael Beck
Michael Beck

Reputation: 76

I did reproduce the error, it seems like the last value in COVID19 was empty:

COVID19<-c("POZİTİF","POZİTİF","POZİTİF","POZİTİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","")

The error doesn't show up when there is a given value, for example

COVID19<-c("POZİTİF","POZİTİF","POZİTİF","POZİTİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF","NEGATİF")

Upvotes: 1

Related Questions