Hidden Markov Model that implements the model described in the
paper.
Emissions are in the form of a list of pairs (pc,r), where pc is a
pitch class (like tonic above) and r is an onset time
abstraction and is one of \{0, ...,3\}.
Unlike with NgramModel, the emission domain is the domain of values
from which each element of an emission is selected. In other words, the
actually domain of emissions is the powerset of
emission_dom.
In the description of the model, r is described as a condition of the
emission distribution. Although the model is truly replicated here, the
interface suggests otherwise, since we treat the rythmic markers as if
they're part of the emissions. From a conceptual point of view, this
makes more sense and I think it's rather odd that the model doesn't treat
them this way.
As for prior distributions (start state distribution), we ignore the
tonic of the first state - it doesn't make any sense to look at it since
the model is pitch-invariant throughout. We then just use our
marginalized chord distribution and assume that the mode distribution is
uniform (there are only two and it probably won't make much
difference).
Note:
mutable distributions: if you use mutable distributions for
transition or emission distributions, make sure you invalidate the
cache by calling clear_cache after updating the distributions.
Various caches are used to speed up retreival of probabilities. If
you fail to do this, you'll end up getting some values
unpredictably from the old distributions
|
|
__init__(self,
key_transition_dist,
chord_transition_dist,
emission_dist,
chord_dist,
model_name='default',
history='',
description='',
chord_set='scale+dom7')
x.__init__(...) initializes x; see help(type(x)) for signature |
source code
|
|
|
|
label(self,
handler)
Produces labels for the midi data using the model. |
source code
|
|
|
|
|
|
|
add_history(self,
string)
Adds a line to the end of this model's history string. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transition_log_probability(self,
state,
previous_state)
Gives the probability P(label_i | label_(i-1), ..., label_(i-n)),
where the previous labels are given in the sequence label_context. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
normal_forward_probabilities(self,
sequence)
If you want the normalized matrix of forward probabilities, it's ok
to use normal (non-log) probabilities and these can be computed more
quickly, since you don't need to sum logs (which is time consuming). |
source code
|
|
|
|
|
|
|
|
|
|
compute_xi(self,
sequence,
forward=None,
backward=None)
Computes the xi matrix used by Baum-Welch. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inherited from utils.nltk.ngram.model.NgramModel:
__repr__,
backward_probabilities,
decode_forward,
decode_gamma,
emission_probability,
forward_backward_log_probabilities,
forward_backward_probabilities,
forward_probabilities,
gamma_probabilities,
generalized_viterbi,
generate,
get_all_ngrams,
get_backoff_models,
get_emission_matrix,
get_transition_matrix,
labeled_sequence_log_probability,
normal_forward_backward_probabilities,
precompute,
transition_log_probability_debug,
transition_probability,
transition_probability_debug,
viterbi_decode,
viterbi_selector_probabilities
Inherited from object:
__delattr__,
__format__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__setattr__,
__sizeof__,
__str__,
__subclasshook__
|
|
|
|
|
|
initialize_chord_types(cls,
probs,
model_name='default',
chord_set='scale+dom7')
Creates a new model with the distributions initialized naively to
favour simple chord-types, as R&S do in the paper. |
source code
|
|
|
|
initialize_existing_model(cls,
old_model_name,
model_name='default')
Initializes a model using parameters from an already trained model. |
source code
|
|
|
|
from_picklable_dict(cls,
data,
model_name='default')
Reproduces an n-gram model that was converted to a picklable form
using to_picklable_dict. |
source code
|
|
|
|
|
|
|
|
|
|
list_models(cls)
Returns a list of the names of available models. |
source code
|
|
|
|
|