You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given the digits dataset (available in sklearn.datasets), we split it into train and test set.
We fit a MultinomialNB classifier on the train set, and generate predictions on that same train
set. When this is done without smoothing, the classification performance is rather low.
This is contrary to expectations, as the classifier has already seen all possible feature values.
So not including smoothing shouldn't really make such a big difference.
It seems the BernoulliNB class from sklearn also has this problem.
Since it's my first time submitting an error report I'm completely lost :(
It says here that PR-s are used to tell others about changes I pushed to a repository. I didn't push anything O_o, nor do I want to. The demo script I submitted (via pastebin link) doesn't fix the issue, or change anything in sklearn code. It's just there to reproduce the issue, so someone who knows the sklearn code can debug it more easily. Perhaps I'm misunderstanding something.
It seems when alpha=0.0 and the data has features which never change, feature_log_prob_ has -inf which causes the calculations down the line to become all nan.
Given
X = np.array([[1, 0],[1, 1]])
y = np.array([0, 1])
Activity
agramfort commentedon Nov 14, 2015
mladenk42 commentedon Nov 14, 2015
Might be a silly question but where do i send it :)? The scikit-learn-issues mailing list?
Thanks.
agramfort commentedon Nov 14, 2015
mladenk42 commentedon Nov 15, 2015
Since it's my first time submitting an error report I'm completely lost :(
It says here that PR-s are used to tell others about changes I pushed to a repository. I didn't push anything O_o, nor do I want to. The demo script I submitted (via pastebin link) doesn't fix the issue, or change anything in sklearn code. It's just there to reproduce the issue, so someone who knows the sklearn code can debug it more easily. Perhaps I'm misunderstanding something.
absolutelyNoWarranty commentedon Nov 19, 2015
It seems when
alpha=0.0and the data has features which never change,feature_log_prob_has-infwhich causes the calculations down the line to become allnan.Given
X = np.array([[1, 0],[1, 1]])
y = np.array([0, 1])
Compare
and
amueller commentedon Sep 14, 2016
We should probably throw an error when that happens if that creates issues.
Fix scikit-learn#5814
yl565 commentedon Sep 24, 2016
@amueller Please see my PR to this issue.
Fix scikit-learn#5814
Fix scikit-learn#5814
jmschrei commentedon Jun 19, 2017
Fixed via #9131
[MRG+1] Fix MultinomialNB and BernoulliNB alpha=0 bug (continuation) (#…
[MRG+1] Fix MultinomialNB and BernoulliNB alpha=0 bug (continuation) (s…
[MRG+1] Fix MultinomialNB and BernoulliNB alpha=0 bug (continuation) (s…
[MRG+1] Fix MultinomialNB and BernoulliNB alpha=0 bug (continuation) (s…
[MRG+1] Fix MultinomialNB and BernoulliNB alpha=0 bug (continuation) (s…
[MRG+1] Fix MultinomialNB and BernoulliNB alpha=0 bug (continuation) (s…
[MRG+1] Fix MultinomialNB and BernoulliNB alpha=0 bug (continuation) (s…
[MRG+1] Fix MultinomialNB and BernoulliNB alpha=0 bug (continuation) (s…