Skip to content

Add bernoulli naive bayes implementation #388

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

Merged
merged 11 commits into from
May 19, 2025
Merged

Conversation

relf
Copy link
Member

@relf relf commented May 6, 2025

This PR supersedes #242

Moreover, NaiveBayes trait is made public as suggested in this comment and provides sklearn-like methods predict_log_proba() and predict_proba() as mentioned in this comment

This PR resolves #183 and also supersedes #385

Copy link

codecov bot commented May 6, 2025

Codecov Report

Attention: Patch coverage is 42.74194% with 71 lines in your changes missing coverage. Please review.

Project coverage is 36.03%. Comparing base (5272ad1) to head (f73bb74).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
algorithms/linfa-bayes/src/bernoulli_nb.rs 47.72% 23 Missing ⚠️
algorithms/linfa-bayes/src/hyperparams.rs 12.00% 22 Missing ⚠️
algorithms/linfa-bayes/src/lib.rs 55.55% 12 Missing ⚠️
algorithms/linfa-bayes/src/base_nb.rs 42.10% 11 Missing ⚠️
algorithms/linfa-bayes/src/multinomial_nb.rs 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #388      +/-   ##
==========================================
+ Coverage   35.90%   36.03%   +0.13%     
==========================================
  Files          97       99       +2     
  Lines        6409     6502      +93     
==========================================
+ Hits         2301     2343      +42     
- Misses       4108     4159      +51     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@relf relf marked this pull request as ready for review May 6, 2025 09:39
@relf relf merged commit 11ea07a into rust-ml:master May 19, 2025
21 checks passed
@relf relf deleted the improve-bayes branch May 19, 2025 14:36
kakserpom pushed a commit to kakserpom/linfa that referenced this pull request Jun 10, 2025
* Add bernoulli Naive Bayes algorithm

* Remove optional from `FitWith` trait implementation

* Move class histogram to root path; Improve example

* Make NaiveBayes public

* Add predict_log_proba and predict_proba

* Review

* Linting

* Revert lint to preserve MSRV

* Add serde for ClassHistogram

* Bump MSRV to 1.82.0

---------

Co-authored-by: Art Wild <[email protected]>
Co-authored-by: Lorenz Schmidt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Multinomial and Bernoulli Naive Bayes algorithms
2 participants