<commit_before>## Latent Dirichelet Allocation with Gibbs sampling

An LDA with Gibbs sampling implementation based on
"Parameter estimation for text analysis" by <NAME>.

Copyright 2013 MIT Center for Civic Media 
Distributed under BSD 3-Clause License, see LICENSE for info

## Dependencies

This library requires the following packages:
* numpy
* scipy

## How to use

For a detailed example see demos/demoldaem.py

First create a numpy array representing a term-document matrix with documents on dimension 0:

    corpus = numpy.array([[1,2,3], [4,5,6], [8,9,0], [9,8,7]])
    
Then create an LDA model, specifying the number of topics.  You can also specify the initial alpha (per-document Dirichlet parameter), eta (per-topic Dirichlet paramter).

    num_topics = 5
    alpha = 0.1
    eta = 0.1
    model = lda.LdaModel(corpus, num_topics, alpha, eta)
    
Then run a numer of EM iterations.

    model.em_iterate(25)

You can the query, for example, the expected per-topic word distributions (beta).

    beta = model.beta()
    print "Word distribution for topic 0: %s" % beta[0]
<commit_msg>Update Readme formatting<commit_after>## Latent Dirichelet Allocation with Gibbs sampling

An LDA with Gibbs sampling implementation based on
"Parameter estimation for text analysis" by <NAME>.

Copyright 2013 MIT Center for Civic Media  
Distributed under BSD 3-Clause License, see LICENSE for info

## Dependencies

This library requires the following packages:
* numpy
* scipy

## How to use

For a detailed example see demos/demoldaem.py

First create a numpy array representing a term-document matrix with documents on dimension 0:

    corpus = numpy.array([[1,2,3], [4,5,6], [8,9,0], [9,8,7]])
    
Then create an LDA model, specifying the number of topics.  You can also specify the initial alpha (per-document Dirichlet parameter), eta (per-topic Dirichlet paramter).

    num_topics = 5
    alpha = 0.1
    eta = 0.1
    model = lda.LdaModel(corpus, num_topics, alpha, eta)
    
Then run a numer of EM iterations.

    model.em_iterate(25)

You can the query, for example, the expected per-topic word distributions (beta).

    beta = model.beta()
    print "Word distribution for topic 0: %s" % beta[0]

{'fraction_non_alphanumeric': 0.08212996389891697, 'fraction_numerical': 0.024368231046931407, 'mean_word_length': 3.883259911894273, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2512436', 'n_tokens_mistral': 703, 'n_tokens_neox': 651, 'n_words': 282}