'tidymodels how to set priors for a Naive Bayes model
I want to train a model with a Naive Bayes classifier using the tidymodels framework.
Tidymodels uses the discrim packages, which itself uses the klaR package to estimate Naive Bayes models.
Specifying a NB model in the tidymodels framework can be done with e.g.:
naive_Bayes(
mode = "classification",
engine = "klaR",
smoothness = NULL,
Laplace = NULL)
When checking the original NB function in the klaR package, though, it has an argument:
prior
the prior probabilities of class membership. If unspecified, the class proportions for the training set are used. If present, the probabilities should be specified in the order of the factor levels.
Problem is, I didn't find a way yet to specify these priors in a tidymodel pipeline. Adding the prior parameter just to the naive_Bayes function shown above, doesn't work and throws an error:
Error in naive_Bayes(prior = rep(0.2, 5)) :
unused argument (prior = rep(0.2, 5))
Any idea where I can make the parameter settings?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
