-
Notifications
You must be signed in to change notification settings - Fork 86
feat: Add getters for naive bayes structs #74
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
feat: Add getters for naive bayes structs #74
Conversation
823dee3
to
64548dc
Compare
Codecov Report
@@ Coverage Diff @@
## development #74 +/- ##
===============================================
+ Coverage 83.77% 83.83% +0.05%
===============================================
Files 75 75
Lines 7803 7850 +47
===============================================
+ Hits 6537 6581 +44
- Misses 1266 1269 +3
Continue to review full report at Codecov.
|
30086a5
to
06fda75
Compare
Hi @morenol. Is this PR still a work in progress or I can review it? |
Hi, @VolodymyrOrlov this is still a work in progress. I'll let you know when this is ready to review |
@@ -223,6 +219,30 @@ impl<T: RealNumber, M: Matrix<T>> GaussianNB<T, M> { | |||
pub fn predict(&self, x: &M) -> Result<M::RowVector, Failed> { | |||
self.inner.predict(x) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -266,6 +266,12 @@ impl<T: RealNumber, M: Matrix<T>> BernoulliNB<T, M> { | |||
self.inner.predict(x) | |||
} | |||
} | |||
|
|||
/// Class labels known to the classifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing:
- [ ] class_log_prior_
- [x] feature_log_prob_
@@ -240,6 +243,18 @@ impl<T: RealNumber, M: Matrix<T>> MultinomialNB<T, M> { | |||
pub fn predict(&self, x: &M) -> Result<M::RowVector, Failed> { | |||
self.inner.predict(x) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing:
- [ ] class_log_prior_
/// Class labels known to the classifier. | ||
/// Returns a vector of size n_classes. | ||
pub fn classes(&self) -> &Vec<T> { | ||
&self.inner.distribution.class_labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- category_count_
- class_log_prior_
- feature_log_prob_
b81111d
to
ed1511c
Compare
ed1511c
to
ecf2b44
Compare
@VolodymyrOrlov Could you kindly review this now? I implemented most of the getters from scikit where we don't need to do extra computations and just access internal data from the structs. For instance, Right now we are storing the class_priors as a probability and in order to get class_log_prior_ we will need to compute the ln of each probability, should we compute that on runtime or store them too in the internal structure? or just ignore those getters for now? |
4d0fb24
to
ae3e3ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Some users might find |
Add classes getter to CategoricalNB Add classes getter to MultinomialNB
f1a55d0
to
04aad18
Compare
This is related to #73:
Things that are done in this PR