-
Notifications
You must be signed in to change notification settings - Fork 47
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 CategoricalNB #313
base: main
Are you sure you want to change the base?
Add CategoricalNB #313
Conversation
Hi @ksew1 and thanks for the pull request! Looks great on the first look and I will be having a detailed review soon. |
}, | ||
x | ||
) do | ||
{_, _, _, jll} = |
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.
As you don't use the first three variables, you can wrap them in a tuple, and then use more convenient pattern match {_, jil}
{i + 1, feature_log_probability, x, jll} | ||
end | ||
|
||
total_jll = jll + class_log_priors |
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.
This can be simply returned
|
||
feature_count = Nx.broadcast(0.0, {num_features, num_classes, num_categories}) | ||
|
||
{_, _, _, _, feature_count} = |
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.
The same as above
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.
I've Dropped some minor comments, but LGMT. There are some part that are common for all of NB algorithms. I think that it will be cool to separate them into utils.ex
inside naive_bayes
dir. But it's not necessary as a scope of this PR.
ad213ec
to
e38812e
Compare
I’ve addressed all the comments 😄. I agree that it would be a good idea to extract the common parts into a separate file. I’ll do this in a separate PR. |
Any reason why |
|
@josevalim @msluszniak I am still having a look. Seems very good, but please give me some time before merging. I might have some improvements to suggest (e.g. maybe the code can be vectorised; this could be valuable for @ksew1 to learn in case they don't know it already). Happy New Year everyone! |
Added CategoricalNB :)