Skip to content

Conversation

@btel
Copy link
Contributor

@btel btel commented Feb 26, 2019

Reference Issues/PRs

Fixes #13232

What does this implement/fix? Explain your changes.

It silences the runtime warning in partial_fit when a target class was not observed, which results in log of 0s. This should not affect the predictions as demonstrated in the implemented unit test. It does have an unpleasant effect of producing -inf in class_log_prior_ attribute when the class was not yet observed. This value is then updated after adding a training case with such a class.

Any other comments?

Ping: @GaelVaroquaux

@agramfort agramfort changed the title Fix warning in MultinomialNB.partial_fit when target class was not yet observed [MRG] Fix warning in MultinomialNB.partial_fit when target class was not yet observed Feb 26, 2019
@GaelVaroquaux
Copy link
Member

LGTM. +1 for merge when CI has run.

@GaelVaroquaux GaelVaroquaux changed the title [MRG] Fix warning in MultinomialNB.partial_fit when target class was not yet observed [MRG+2] Fix warning in MultinomialNB.partial_fit when target class was not yet observed Feb 26, 2019
@qinhanmin2014
Copy link
Member

this PR also solves similar issues in ComplementNB and BernoulliNB, right?

@qinhanmin2014 qinhanmin2014 merged commit 0682d92 into scikit-learn:master Feb 26, 2019
@btel
Copy link
Contributor Author

btel commented Feb 26, 2019

@qinhanmin2014 yes, you are right. The check is implemented in base class, so it should work also for the other NB models.

xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
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.

partial_fit does not account for unobserved target values when fitting priors to data

4 participants