| Trees | Indices | Help |
|
|---|
|
|
object --+
|
utils.nltk.ngram.model.NgramModel --+
|
MultiChordNgramModel
An ngram model that takes multiple chords (weighted by probability) as input to its decoding. It is trained on labeled data.
State labels are pairs (root,schema), each representing a lexical schema instantiated on a specific root, i.e. a lexical category. Emissions are pairs (root,label), representing chords. The parameters are tied so that chords (r,l) can only be emitted from states (r,s).
The component distributions that are actually stored are:
emission_dist
schema_transition_dist
root_transition_dist
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from Inherited from |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from |
|||
|
|||
x.__init__(...) initializes x; see help(type(x)) for signature
|
Initializes or empties probability distribution caches. Make sure to call this if you change or update the distributions. No caches used thus far, so this does nothing for now, except call the super method. |
Initializes and trains an HMM in a supervised fashion using the given
training data. Training data should be chord sequence data (input type
|
Returns the amount to scale the backed off probabilities by when backing off to an order n-1 model in the given context. This is presented as alpha in Jurafsky and Martin. Returned as a base 2 log. A more efficient way to do this would be to supply a function of the context specific to the discounting technique. In this case it wouldn't be necessary to sum the discounted mass each time.
|
Just the schema part of the transition distribution. This method takes just schemata as args, instead of whole states. |
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. |
Emission matrix for states decomposed into schema and root. Matrix has dimensions (time, root, schema). |
Return the forward probability matrix as a Numpy array. This is equivalent to forward_probabilities, but much faster. It doesn't need logs because it's normalizing at each timestep.
See Also: jazzparser.utils.nltk.ngram.model.NgramModel.normal_forward_probabilities Note: tested against superclass method. They're giving the same results to a high precision (differences ~1e-20) |
Return the backward probability matrices a Numpy array. This is faster than backward_log_probabilities because it uses Numpy arrays with non-log probabilities and normalizes each timestep.
See Also: jazzparser.utils.nltk.ngram.model.NgramModel.normal_backward_probabilities |
State-occupation probabilities. Overridden so we don't need to construct the full ngram matrix, which can be huge with trigrams to the point of running out of memory.
|
Alias for backward compatibility. Use
|
Produces a picklable representation of model as a dict. |
Reproduces an model that was converted to a picklable form using to_picklable_dict. |
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Mon Nov 26 16:04:58 2012 | http://epydoc.sourceforge.net |