在 R 中使用 naivebayes 和 Caret 实现朴素贝叶斯分类器
我有一个使用 naivebayes 包的现有预测模型。我目前正在尝试做的是使用 Caret 复制我的模型。这样做的原因是因为我想运行 varImp() 函数来查看插入符号中的重要变量列表。我已经成功地使用 Caret 运行朴素贝叶斯分类器,但问题是,当我进行预测以确保使用 Caret 的模型与使用 naivebayes 的模型一致时,我最终会得到不同的结果。有人可以建议我如何使用 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)
提前非常感谢。
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论