| Trees | Indices | Help |
|
|---|
|
|
object --+
|
utils.nltk.ngram.model.NgramModel --+
|
HmmPathNgram
An ngram model that takes multiple chords (weighted by probability) as input to its decoding. It is trained on labeled data.
This is similar to jazzparser.taggers.ngram_multi.model.MultiChordNgramModel, but the states represent points on a TS path, rather than categories.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from Inherited from |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from |
|||
|
|||
x.__init__(...) initializes x; see help(type(x)) for signature
|
Initializes and trains an HMM in a supervised fashion using the given
training data. Training data should be chord sequence data (input type
|
Gives the probability P(label_i | label_(i-1), ..., label_(i-n)), where the previous labels are given in the sequence label_context. The context should be in reverse order, i.e. with the most recent label at the start. Note that this is the probability of a label given the previous n-1 labels, which is the same as the probability of the n-gram [label_i, ..., label_(i-n+1)] given the ngram [label_(i-1), ..., label_(i-n)], since all but the last element of the ngram overlaps with the condition, so has probability 1. Caches all computed transition probabilities. This is particularly important for backoff models. Many n-grams will back off to the same (n-1)-gram and we don't want to recompute the transition probability for that each time.
|
Gives the probability P(emission | label). Returned as a base 2 log. The emission should be a pair of (root,label), together defining a chord. There's a special case of this. If the emission is a list, it's assumed to be a distribution over emissions. The list should contain (prob,em) pairs, where em is an emission, such as is normally passed into this function, and prob is the weight to give to this possible emission. The probabilities of the possible emissions are summed up, weighted by the prob values. |
Produces a picklable representation of model as a dict. You can't just pickle the object directly because some of the NLTK classes can't be pickled. You can pickle this dict and reconstruct the model using NgramModel.from_picklable_dict(dict).
|
Reproduces an n-gram model that was converted to a picklable form using to_picklable_dict. Extra args/kwargs are passed to the class constructor.
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Nov 26 16:04:56 2012 | http://epydoc.sourceforge.net |