Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b29e82

Browse files
committed
Revert "ENH: avoid an underflow"
That was a bad idea: this underflow is happening because there is only onlyone class This reverts commit 65abbb6.
1 parent 65abbb6 commit 5b29e82

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

sklearn/naive_bayes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ def fit(self, X, y, sample_weight=None, class_prior=None):
266266
elif self.fit_prior:
267267
# empirical prior, with sample_weight taken into account
268268
y_freq = Y.sum(axis=0)
269-
eps = np.finfo(1.).eps
270-
self.class_log_prior_ = (np.log(y_freq + eps)
271-
- np.log(y_freq.sum() + eps))
269+
self.class_log_prior_ = np.log(y_freq) - np.log(y_freq.sum())
272270
else:
273271
self.class_log_prior_ = np.zeros(n_classes) - np.log(n_classes)
274272

0 commit comments

Comments
 (0)