Closed smalik89 closed 1 year ago
You need to either initialize the model with a structure by adding edges and nodes using the add_edge
and add_nodes
method, the from_matrix
method, or you need to use the from_samples
method to learn a dense HMM directly from data. Using the fit
method only updates parameters given a structure, but you haven't given it a structure.
Hi @jmschrei ! I used the from_samples
method however, still getting an error with 'dist'. I used the documentation to set up a supervised prediction however still get an issue. Can you point me in the right direction or any recommendations?
# Supervised method that calculates the transition matrix:
d1 = State(UniformDistribution.from_samples([3.243221498397177, 3.210684537495482, 3.227662201472816,
3.286410817416738, 3.290573650708864, 3.286058136226862, 3.266480693857006]))
d2 = State(UniformDistribution.from_samples([3.449282367485096, 1.97317859465635, 1.897551432353011,
3.454609351559659, 3.127357456033111, 1.779308337786426, 3.802891929694426, 3.359766157565077, 2.959428499979418]))
d3 = State(UniformDistribution.from_samples([1.892812118441474, 1.589353118681066, 2.09269978285637,
2.104391496570218, 1.656771181054144]))
model = HiddenMarkovModel()
model.add_states(d1, d2, d3)
model.bake()
model.fit([3.2, 6.7, 10.55], labels=[1, 2, 3], algorithm='labeled')
all_pred = model.predict([2.33, 1.22, 1.4, 10.6])
Issue:
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-8-760ac26056e1>", line 9, in <module>
model.bake()
File "pomegranate/hmm.pyx", line 1047, in pomegranate.hmm.HiddenMarkovModel.bake
UnboundLocalError: local variable 'dist' referenced before assignment
Many Thanks for your help with this, really appreciate it!
Not sure where to post this (as Discussions aren`t enabled in this repository), so here's (what I consider) the 2nd best place.
There's a big discrepancy between the versions published on [PyPI]: Pomegranate and the corresponding tags (which should indicate the source code states used to build those versions) in this repository, so when a problem arises (and it will definitely will, as there are some places in the code that don't handle "special" cases) it's hard to watch (and fix) such a problem. Would it be possible to also list the latest tags (e.g v.14.*)?
Thank you for opening an issue. pomegranate has recently been rewritten from the ground up to use PyTorch instead of Cython (v1.0.0), and so all issues are being closed as they are likely out of date. Please re-open or start a new issue if a related issue is still present in the new codebase.
Describe the bug Trying to do a supervised training with pomegranate.hmm.HiddenMarkovModel. Expecting to train the model and test on observations. However this is the err even though not using dist:
Pomegranate Version: 0.14.4:
To Reproduce
Thank you so much for your thoughts on this.