Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6f67a81
Showing
10 changed files
with
9,050 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
Oops, something went wrong.