I am trying to run a simple naive bayes model (trying to redo what I have seen the datacamp course).
I am using the R naivebayes
package.
The training dataset is where9am
which looks like this:
My first problem is the following... when I have several predictions in a dataframe thursday9am
...
... and I use the following code:
locmodel <- naive_bayes(location ~ daytype, data = where9am)
my_pred <- predict(locmodel, thursday9am)
I get a series of <NA>
while it works well with the correct prediction if the thursday9am
dataframe only contains a single observation.
The second problem is the following: when I use the following code to get the associated probabilities...
locmodel <- naive_bayes(location ~ daytype, data = where9am, type = c("class", "prob"))
predict(locmodel, thursday9am , type = "prob")
... even if I have only one observation in thursday9am
, I get a series of <NaN>
.
I am not sure what I am doing wrong.