Giter VIP home page Giter VIP logo

jslda's Introduction

jsLDA

An implementation of latent Dirichlet allocation in javascript. A live demonstration is available.

Instructions:

When you first load the page, it will request a file containing documents and a file containing stopwords. The default example is a corpus of paragraphs from US State of the Union speeches.

Click the "Run 50 iterations" button to start training. The browser may appear to freeze for a while. Initially all words have been assigned randomly to topics. We train a model by cycling through every word token in the documents and sampling a topic for that word. An "iteration" corresponds to one pass through the documents.

The topics on the left side of the page should now look more interesting. Run more iterations if you would like -- there's probably still a lot of room for improvement after only 50 iterations.

Once you're satisfied with the model, you can click on a topic from the list on the right to sort documents in descending order by their use of that topic. Proportions are weighted so that longer documents will come first.

You can also explore correlations between topics by clicking the "Topic Correlations" tab. This view shows a force directed layout with connections between topics that have correlations above a certain threshold. You can control this threshold with the slider: a low cutoff will display more edges, while a high cutoff will remove all but the strongest correlations.

Topic correlations are actually pointwise mutual information scores. This score measures whether two topics occur in the same document more often than we would expect by chance. Previous versions of this script calculated correlations on logratios; PMI is simpler to calculate.

Using your own corpus:

To use your own corpus, the best way is to place the files in this repository in the document root of a web server. Replace the files documents.txt and stoplist.txt with your own corpus and stop list. The documents file is a tab-delimited text file with one document per line. Each line has three fields:

[doc ID] [tab] [label] [tab] [text...]

(this is the default format for Mallet). The "label" field is currently unused, but I plan to support timestamps, labels, etc.

The format for stopwords is one word per line. The "Vocabulary" tab may be useful in customizing a stoplist. Unicode is supported, so most languages that have meaningful whitespace (ie not CJK) should work.

The page works best in Chrome. Safari and Firefox work too, but may be considerably slower. It doesn't seem to work in IE.

Download results:

You can create reports about your topic model. Hit the Downloads tab. Reports are in CSV format. The sampling state file contains the same information as a Mallet state file, but in a more compact format.

jslda's People

Contributors

mimno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jslda's Issues

Question about "topicNormalizers"

David,

What use cases will this be most useful? I would like to learn more about this.

Thanks,

Owen Dall

var topicNormalizers = zeros(numTopics);
    for (var topic = 0; topic < numTopics; topic++) {
        topicNormalizers[topic] = 1.0 / (vocabularySize * topicWordSmoothing + tokensPerTopic[topic]);
    }

(And then two other places: line 258 and 296.

Can't load sotu_stop.txt

Problem:
When I click on buttons "Documents", "Vocabulary", "Topic Correlations" - nothing seems to happen.
Steps to reproduce:

  1. Download the zip archive of source.
  2. Open jslda.html file with the Chrome browser (Version 34.0.1847.131)
  3. Hit Command+I to bring up the developer console.
  4. Notice the following error messages:

"XMLHttpRequest cannot load file:///path/to/dir/jsLDA-master/sotu_stop.txt. Cross origin requests are only supported for HTTP. "
"Uncaught NetworkError: A network error occurred. "

Platform: MacBook Pro, OS X 10.9.2

Parameter question

var correlationCutoff = 0.25;

Should the parameter "cutoff" in the function getCorrelationGraph actually be "correlationCuttoff"?

"function var getCorrelationGraph = function(correlationMatrix, cutoff)"

Stoplist.txt not working properly

Working with polytonic greek text (Unicode):

  • Doesn't recognise any stopword

But

  • If there is only one word in stoplist.txt, that one is excluded correctly
  • If there are more than one, only the last one is excluded.

Forked jsLDA and am refactoring the JS/HTML/CSS

Hi David,

I will let you know when phase 1 is complete to see if you are interested in using any of it. Using a responsive layout and perhaps will migrate to React.js. in Phase 2.

Thanks so much for sharing this! Please advise if you have suggested modifications to any of the algorithms.

Owen Dall

Licensing & other questions

Hi Mimno

These two github repos kick ass. How are they licensed? In particular, this one (jsLDA) - could you clarify the relationship between the algorithm you are using here and the Mallows-based one you are using in your anchor repo.

The code qual looks excellent - can I use this on a personal project?

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.