04b4eb0d841f8dfe1d095b2af4bcf57cda72c1d2,lxmls/classifiers/multinomial_naive_bayes.py,MultinomialNaiveBayes,train,#MultinomialNaiveBayes#Any#Any#,16
Before Change
likelihood[:,i] = value // likelihood = count of occurrences of a word in a class
// NOTE: at this point this is a count, not a likelihood
for f in xrange(nr_f):
for i in xrange(nr_c):
if self.smooth:
likelihood[f,i] = (self.smooth_param + likelihood[f,i])/(nr_f*self.smooth_param + sums[f,0]) // Add-one smoothing
else:
likelihood[f,i] = likelihood[f,i]/sums[f,0]
params = np.zeros((nr_f+1,nr_c))
for i in xrange(nr_c):
params[0,i] = np.log(prior[i])
params[1:,i] = np.nan_to_num(np.log(likelihood[:,i]))
After Change
prior[i] = 1.0*len(idx)/len(y)
// compute word counts for this class
class_count[:,i] = sum(x[idx,:],0)
total_count[:,0] += sum(x[idx,:],0)
// Compute likelihood from counts, special
if self.smooth:
likelihood = (self.smooth_param + class_count)/(total_count + nr_f*self.smooth_param)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances Project Name: LxMLS/lxmls-toolkit
Commit Name: 04b4eb0d841f8dfe1d095b2af4bcf57cda72c1d2
Time: 2012-07-11
Author: ramon@astudillo.com
File Name: lxmls/classifiers/multinomial_naive_bayes.py
Class Name: MultinomialNaiveBayes
Method Name: train
Project Name: nilearn/nilearn
Commit Name: d355f7fa74f8dd03b2e431b80b1a59c3bae70740
Time: 2013-08-26
Author: philippe.gervais@inria.fr
File Name: nisl/honorio_samaras.py
Class Name:
Method Name: honorio_samaras
Project Name: LxMLS/lxmls-toolkit
Commit Name: 120d63209adb69e23cf44b8017c3506d325eac7d
Time: 2013-06-14
Author: miguelbalmeida@gmail.com
File Name: code/classifiers/multinomial_naive_bayes.py
Class Name: MultinomialNaiveBayes
Method Name: train