Skip to content
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 bernoulli naive bayes implementation #242

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

bytesnake
Copy link
Member

Continuation of #226

@bytesnake bytesnake mentioned this pull request Aug 30, 2022
@bytesnake
Copy link
Member Author

error: package time v0.3.14 cannot be built because it requires rustc 1.59.0 or newer, while the currently active rustc version is 1.57.0

not sure which dependency causes this issue

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2022

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 56.93431% with 59 lines in your changes missing coverage. Please review.

Project coverage is 55.57%. Comparing base (d3464d7) to head (639ccd3).
Report is 45 commits behind head on master.

Files with missing lines Patch % Lines
algorithms/linfa-bayes/src/bernoulli_nb.rs 64.28% 25 Missing ⚠️
algorithms/linfa-bayes/src/hyperparams.rs 12.00% 22 Missing ⚠️
algorithms/linfa-bayes/src/lib.rs 65.38% 9 Missing ⚠️
algorithms/linfa-bayes/src/multinomial_nb.rs 76.92% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #242      +/-   ##
==========================================
- Coverage   55.59%   55.57%   -0.02%     
==========================================
  Files          96       98       +2     
  Lines        8951     9042      +91     
==========================================
+ Hits         4976     5025      +49     
- Misses       3975     4017      +42     

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

@YuhanLiin
Copy link
Collaborator

Seems like we need to bump MSRV to 1.59 (or limit the time dependency to a lower version)

Comment on lines +175 to +181
let thr = self.binarize.unwrap_or_else(F::zero);
let xbin = x.map(|v| if v > &thr { F::one() } else { F::zero() });
if self.binarize.is_some() {
CowArray::from(xbin)
} else {
CowArray::from(x)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you write the logic like:

if let Some(thr) = self.binarize {
   ...
} else {
  ...
}

// Threshold for binarization
binarize: Option<F>,
// Phantom data for label type
label: PhantomData<L>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this phantomdata?

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.

4 participants