There are two data frames: trainReady
(288obs.) and testReady
(112obs.). These data frames contains 55 attributes (54 continuous and 1 binary, class attribute). I have already discretized those 54 attributes to 10 divisions, levels (with equal number of observations per level assumption). The number of obs. of both classes in trainReady
is nearly equal. In testReady
too. Class attribute is treated as factor. Below I am posting pieces of data frames:
trainReady
When I try to run those lines (as you can see I have set the threshold to omit "0-frequency" problem):
model_bayes <- naiveBayes(isFace ~ ., data = trainReady)
prediction <- predict(model_bayes, testReady[,-1], threshold = 0.001, eps = 0)
I receive:
Error in [.default(object$tables[[v]], , nd + islogical[attribs[v]]) :
subscript out of bounds
What I have already done to help myself with overcoming the problem:
model_bayes <- naiveBayes(isFace ~ ., data = trainReady, drop.unused.levels = FALSE)
- Predicting on the data which had been used to train model:
prediction <- predict(model_bayes, trainReady[,-1], threshold = 0.001, eps = 0)
1 does not work, 2 works but I would like to predict on the test data. Could you tell me how can I overcome the problem?