Permalink
Browse files

eliminated logfac from source code altogether

  • Loading branch information...
1 parent 6f7611d commit 66412f60f1141a2e097847928ca83755b405e774 @saffsd committed Jul 4, 2012
Showing with 2 additions and 13 deletions.
  1. +2 −13 langid.py
View
@@ -132,24 +132,13 @@ def set_languages(langs):
nb_ptc = nb_ptc[:,subset_mask]
nb_pc = nb_pc[subset_mask]
-
- __logfac = {}
- def logfac(a):
- if a not in __logfac:
- __logfac[a] = np.sum(np.log(np.arange(1,a+1)))
- return __logfac[a]
- logfac = np.frompyfunc(logfac, 1, 1)
-
def argmax(x):
return np.argmax(x)
def nb_classprobs(fv):
- # compute the log-factorial of each element of the vector
- #logfv = logfac(fv).astype(float)
- # compute the probability of the document given each class
- #pdc = np.dot(fv,nb_ptc) - logfv.sum()
+ # compute the partial log-probability of the document given each class
pdc = np.dot(fv,nb_ptc)
- # compute the probability of the document in each class
+ # compute the partial log-probability of the document in each class
pd = pdc + nb_pc
return pd

0 comments on commit 66412f6

Please sign in to comment.