'Implementing Naive Bayes Classifier with naivebayes and Caret in R
I have an existing predictive model using naivebayes package. What I'm currently trying to do is replicate my model using Caret. The reason for this is because I'd like to run varImp() function to see the list of significant variables from Caret. I have managed to run Naive Bayes Classifier using Caret, but the problem is that when I do the prediction to make sure the model from using Caret aligns with the model from using naivebayes, I end up with different results. Could someone please advice how I can replicate my existing Naive Bayes Classifier using Caret?
# Naive Bayes Classifier using naivebayes
nb = naive_bayes(y ~ ., data = df, usekernel = T)
# Naive Bayes Classifier using Caret
Grid = data.frame(usekernel = TRUE, laplace = 0, adjust = 1)
caret = train(y ~ ., data = df,
method = 'naive_bayes',
na.action = na.pass,
trControl = trainControl(method = "none"),
tuneGrid = Grid)
Much appreciated in advance.
Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
