Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
qpleple committed May 31, 2012
0 parents commit 6f67a81
Show file tree
Hide file tree
Showing 10 changed files with 9,050 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .gitignore
@@ -0,0 +1,36 @@
*.py[cod]

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

#Translations
*.mo

#Mr Developer
.mr.developer.cfg

.DS_Store
*.dat
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions README.md
@@ -0,0 +1,3 @@
Online Latent Dirichlet Allocation
===
Online inference for the Latent Dirichlet Allocation probabilistic topic model by Matt Hoffman <mdhoffma@cs.princeton.edu>
33 changes: 33 additions & 0 deletions disptopics.py
@@ -0,0 +1,33 @@
import sys, os, re, random, math, urllib2, time, cPickle
import numpy
from termcolor import colored
import onlineldavb

def blah(testlambdaLine):
lambdak = list(testlambdaLine)
lambdak = lambdak / sum(lambdak)
temp = zip(lambdak, range(0, len(lambdak)))
return sorted(temp, key = lambda x: x[0], reverse=True)

def main():
"""
Displays topics fit by onlineldavb.py. The first column gives the
(expected) most prominent words in the topics, the second column
gives their (expected) relative prominence.
"""
print colored('Loading', 'yellow')
vocab = str.split(file(sys.argv[1]).read())
testlambda1 = numpy.loadtxt(sys.argv[2])
testlambda2 = numpy.loadtxt(sys.argv[3])

for k in range(0, len(testlambda1)):
temp1 = blah(testlambda1[k, :])
temp2 = blah(testlambda2[k, :])
# print 'topic %d:' % (k)
# feel free to change the "53" here to whatever fits your screen nicely.
print colored("Topic %s" % k, 'green')
print ' '.join([vocab[temp1[i][1]] for i in range(0, 10)])
print colored(' '.join([vocab[temp2[i][1]] for i in range(0, 10)]), 'yellow')

if __name__ == '__main__':
main()

0 comments on commit 6f67a81

Please sign in to comment.