-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Multinomial and Bernoulli Naive Bayes algorithms #183
Comments
Hi @sgrigory,
no not really, the question is rather how we want to add them. The type system should allow us to be generic over the distribution, there are some distribution libraries in Rust but few with MAP estimation.
sounds like a good candidate for a trait
👍
yes, we would accept such a PR. To be really useful, we have to figure out how-to
It may therefore be refactored in the future, but nevertheless we will accept such a PR gladly :) |
Hi. I have tried multinomial naive bayes and it works very well in predicting the correct result. However, in some cases I need to get the joint likelihood for further calculations, but I cannot get those numbers because the corresponding function is in |
That would require making the |
Currently
linfa-bayes
crate contains Gaussian Naive Bayes algorithm. It should not be very difficult to add other kinds of Naive Bayes present insklearn
:For a new algorithm one needs to reimplement methods
joint_log_likelihood
andupdate_feature_log_prob
and the hyperparameters - the rest of the code stays more or less the same.I have created a draft implementation of Multinomial Naive Bayes in this branch, based on the current code of Gaussian Naive Bayes and the sklearn implementation of MultinomialNB. At the moment a large part of code is copy-pasted from Gaussian Naive Bayes, but it is possible to refactor both to deduplicate the shared code.
Would you consider this a useful feature to have? If yes, I can finalise the draft and open a PR .
@VasanthakumarV @bytesnake, tagging you since you authored and reviewed the original Gaussian Naive Bayes implementation in #51
The text was updated successfully, but these errors were encountered: