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

Implement GeneralNB #15077

Open
qinhanmin2014 opened this issue Sep 24, 2019 · 4 comments
Open

Implement GeneralNB #15077

qinhanmin2014 opened this issue Sep 24, 2019 · 4 comments

Comments

@qinhanmin2014
Copy link
Member

Open an issue to discuss the implementation of GeneralNB (combine different naive bayes estimators to support different types of features)
Related issue: #10856 #12957

@remykarem
Copy link

remykarem commented Oct 23, 2019

@qinhanmin2014, here is my preliminary suggestion. The implementation for GeneralNB is slated for the 5 naive Bayes algorithms that sklearn has GaussianNB, BernoulliNB, MultinomialNB, ComplementNB and CategoricalNB.

An sklearn user would expect to use GeneralNB in this manner:

import numpy as np
from sklearn.naive_bayes import GaussianNB, BernoulliNB, 

X = np.array([[1.5, 2.3, 0, 1],
              [2.7, 3.8, 1, 0],
              [1.7, 0.1, 1, 0]])
y = np.array([1,0,2])

generalnb = GeneralNB([(GaussianNB(), [0,1]), (BernoulliNB(), [2,3])])
generalnb.fit(X, y)

In general how I would implement the GeneralNB.fit() function is to run fit() on the respective naive Bayes objects.

For the GeneralNB.predict() function, we could sum the _joint_log_likelihood() for each object, and subtract (n-1) log P(c) from this sum.

Let me know what are your thoughts on this or if I missed something out.

@qinhanmin2014
Copy link
Member Author

Thanks, I think this is what we want.
Actually there's an annoying blocker #14444, but you can start to draft a PR. It's not likely to be included in the next release so please be patient.

@remykarem
Copy link

Got it, I will start working on it.

@avm19
Copy link
Contributor

avm19 commented Feb 11, 2022

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants