scikit-learn/scikit-learn — pull request #731 by udi (2012-03-26 21:22:07+00:00)
Title: Fixed a bug in GaussianNB (naive_bayes.py)

In GaussianNB, the computation of the class priors was:
self.class_prior_[i] = np.float(np.sum(y == y_i)) / n_classes

Which is wrong. Finding the probability of the class should be using;
self.class_prior_[i] = np.float(np.sum(y == y_i)) / n_samples

with n_samples simply be:
n_samples, n_features = X.shape

I've fixed this issue in the code.

The effect of this bug can be quite significant, because instead of probability (a value between 0 and 1), the class_prior_ is a (possible) large number (much larger than the probabilities of the different features), thus it can bias the results towards the class priors, with little value assigned to the actual features.