Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

eliminated logfac from source code altogether

  • Loading branch information...
commit 66412f60f1141a2e097847928ca83755b405e774 1 parent 6f7611d
@saffsd authored
Showing with 2 additions and 13 deletions.
  1. +2 −13 langid.py
View
15 langid.py
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.