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 Report

Base: 55.59% // Head: 55.52% // Decreases project coverage by -0.06% ⚠️

Coverage data is based on head (639ccd3) compared to base (d3464d7).
Patch coverage: 56.93% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #242      +/-   ##
==========================================
- Coverage   55.59%   55.52%   -0.07%     
==========================================
  Files          96       98       +2     
  Lines        8951     9042      +91     
==========================================
+ Hits         4976     5021      +45     
- Misses       3975     4021      +46     
Impacted Files Coverage Δ
algorithms/linfa-bayes/src/base_nb.rs 60.00% <ø> (-6.67%) ⬇️
algorithms/linfa-bayes/src/hyperparams.rs 9.52% <12.00%> (-1.01%) ⬇️
algorithms/linfa-bayes/src/bernoulli_nb.rs 64.28% <64.28%> (ø)
algorithms/linfa-bayes/src/lib.rs 65.38% <65.38%> (ø)
algorithms/linfa-bayes/src/multinomial_nb.rs 67.21% <76.92%> (+3.35%) ⬆️
algorithms/linfa-bayes/src/gaussian_nb.rs 62.88% <100.00%> (ø)
...rithms/linfa-trees/src/decision_trees/algorithm.rs 48.26% <0.00%> (-1.57%) ⬇️
algorithms/linfa-nn/src/kdtree.rs 48.64% <0.00%> (-1.36%) ⬇️
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@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.

None yet

4 participants