The principle of BTM is very similar to LDA, and here is the probability plot for the model:
It can be seen from the graph that the difference between the LDA is to determine the topic distribution and Word distribution corresponding to take two words (and LDA only one, that is, the analogy of the common dice: the first throw K-face dice to get the theme Z, and then according to the corresponding V-face dice, throw two times, get a pair of vocabulary ), these two words are called biterm(that is, after a document word breaker, the set of these words a distance indicator, from the first to the J words between 22 pairs, can be regarded as a pair of biterm). Get the Biterm code from the original document as follows:
def build_biterms (self, sentence):
"""
Get biterms of document
:P Aram Sentence:word ID list sentence is the ID of each word after the word is cut
: Return:biterm List
"""
Win = # set window size
Biterms = []
For i in xrange (len (sentence)-1):
For J in xrange (i+1, min (i+win+1, len (sentence))):
Biterms.append (biterm (int (sentence[i)),Int (sentence[j] ))
Return biterms
BTM uses the entire text set to estimate a theta, which solves the sparse problem (we usually have a huge amount of data). Relaxed the mixture of unigram the entire document must belong to a subject Z (equivalent to two words relaxed from the entire document to the window length), Reinforced the assumption that each word in LDA corresponds to a Z (the two words in BTM that constrain the length of a window make up a biterm corresponds to a z). This hypothesis is very close to human cognition, as we know that topic often changes little in a shorter text.
BTM Learning Little Mind