mattjj / pyhsmm

MIT License
546 stars 173 forks source link

errors when running pyhsmm and pybasicbayes examples #51

Closed andrwz closed 8 years ago

andrwz commented 8 years ago

Dear Matthew,

I successfully (at least I think I have) installed pyhsmm and pybasicbayes.

I did try to run all the examples from the directory "..pyhsmm/examples/", but I could not make some of them to work.

As you might tell, this is my first time using python and I believe I am missing something fundamental here, so I apologize in advance for my dumb questions hoping for a trivial solution.

The following are the issues I encountered when running some of the examples in pyhsmm and pybasicbayes.

1) when running pyhsmm/examples/hmm-separatetrans.py AttributeError: 'HMMSeparateTrans' object has no attribute 'trans_distn'

2) when running pyhsmm/examples/hsmm-possiblechangepoints-meanfield.py AttributeError: 'module' object has no attribute 'DiagGaussGMMHSMMPossibleChangepointsSeparateTrans'

3) when running pyhsmm/examples/hsmm-possiblechangepoints-separatetrans.py AttributeError: 'HSMMPossibleChangepointsSeparateTrans' object has no attribute 'init_state_distn'

4) when running pyhsmm/examples/hsmm-possiblechangepoints.py AttributeError: 'module' object has no attribute 'DiagGaussGMMHSMMPossibleChangepointsSeparateTrans'

5) When running pybasicbayes/examples/EM-demo.py

data = data if data else [None]*len(weights)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

6) When running animation.py the program keeps dumping number and labels on the screen indefinetely.

Please find below full trace for 1-5 of the above, any suggestion you might have on how to solve these would be very much appreciated. Best regards


1) C:\Users\Documents\python\pyhsmm\examples>python hmm-separatetrans.py Traceback (most recent call last): File "hmm-separatetrans.py", line 44, in model.add_data(group_id=group_id,data=data) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\models.py", line 68, in add_data stateseq=stateseq,kwargs)) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hmm_states.py", line 113, in init super(_SeparateTransMixin,self).init(kwargs) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hmm_states.py", line 37, in init self.generate_states() File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hmm_states.py", line 585, in generate_states trans_matrix=self.trans_matrix, File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hmm_states.py", line 121, in trans_matrix return self.model.trans_distns[self.group_id].trans_matrix File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\models.py", line 1221, in lambda: copy.deepcopy(self.trans_distn)) AttributeError: 'HMMSeparateTrans' object has no attribute 'trans_distn'


2) when running pyhsmm/examples/hsmm-possiblechangepoints-meanfield.py

C:\Users\Documents\python\pyhsmm\examples>python hsmm-possiblechangepoints-meanfield.py segments: [(0, 47), (47, 83), (83, 114), (114, 153), (153, 191), (191, 218), (218, 264), (264, 301), (301, 337), (337, 380), (380, 409), (409, 454), (454, 486), (486, 516), (516, 558), (558, 590), (590, 617), (617, 647), (647, 686), (686, 719), (719, 757), (757, 799), (799, 831), (831, 862), (862, 894), (894, 937), (937, 968), (968, 1000)] Traceback (most recent call last): File "hsmm-possiblechangepoints-meanfield.py", line 65, in posteriormodel = pyhsmm.models.DiagGaussGMMHSMMPossibleChangepointsSeparateTrans( AttributeError: 'module' object has no attribute 'DiagGaussGMMHSMMPossibleChangepointsSeparateTrans'


3) when running pyhsmm/examples/hsmm-possiblechangepoints-separatetrans.py

C:\Users\Documents\python\pyhsmm\examples>python hsmm-possiblechangepoints-separatetrans.py Traceback (most recent call last): File "hsmm-possiblechangepoints-separatetrans.py", line 73, in posteriormodel.add_data(data=data,changepoints=changepoints,group_id=idx) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\models.py", line 731, in add_data data=data,changepoints=changepoints,kwargs) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\models.py", line 896, in add_data kwargs)) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hmm_states.py", line 113, in init super(_SeparateTransMixin,self).init(kwargs) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hmm_states.py", line 153, in init model,T=len(changepoints),data=data,kwargs) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hsmm_states.py", line 25, in init super(HSMMStatesPython,self).init(model,stateseq=stateseq,kwargs) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hmm_states.py", line 37, in init** self.generate_states() File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hsmm_states.py", line 829, in generate_states nextstate_distr = self.pi_0 File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\internals\hmm_states.py", line 125, in pi_0 return self.model.init_state_distns[self.group_id].pi_0 File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pyhsmm\models.py", line 1223, in lambda: copy.deepcopy(self.init_state_distn)) AttributeError: 'HSMMPossibleChangepointsSeparateTrans' object has no attribute 'init_state_distn'


4) when running pyhsmm/examples/hsmm-possiblechangepoints.py

C:\Users\Documents\python\pyhsmm\examples>python hsmm-possiblechangepoints.py segments: [(0, 47), (47, 83), (83, 114), (114, 153), (153, 191), (191, 218), (218, 264), (264, 301), (301, 337), (337, 380), (380, 409), (409, 454), (454, 486), (486, 516), (516, 558), (558, 590), (590, 617), (617, 647), (647, 686), (686, 719), (719, 757), (757, 799), (799, 831), (831, 862), (862, 894), (894, 937), (937, 968), (968, 1000)] Traceback (most recent call last): File "hsmm-possiblechangepoints.py", line 65, in posteriormodel = pyhsmm.models.DiagGaussGMMHSMMPossibleChangepointsSeparateTrans( AttributeError: 'module' object has no attribute 'DiagGaussGMMHSMMPossibleChangepointsSeparateTrans'


5) when running \pybasicbayes\examples\EM_demo.py

C:\Users\Documents\python\pybasicbayes\examples>python EM_demo.py .Traceback (most recent call last): File "EM_demo.py", line 54, in fitmodel.EM_step() File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pybasicbayes\models.py", line 480, in EM_step [l.expectations for l in self.labels_list]) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pybasicbayes\distributions\multinomial.py", line 188, in max_like lihood counts = self._get_weighted_statistics(data,weights) File "C:\Users\Anaconda\envs\mscenv01\lib\site-packages\pybasicbayes\distributions\multinomial.py", line 138, in _get_wei ghted_statistics data = data if data else [None]*len(weights) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

mattjj commented 8 years ago

Some of these files are old and haven't been updated. I should probably delete them.

animation.py dumps to the screen because I had a demo where I plugged that stream into a node.js server, sent it over a websocket to a browser, and then rendered the fitting process in d3.js in real-time (much faster than matplotlib!).

Do you care about any of these demos in particular? If there's one that is relevant, I might be able to fix it up instead of deleting it.

mattjj commented 8 years ago

Removed a bunch of examples in 78d9e80.

andrwz commented 8 years ago

Hi Matthew, thank you for your reply. I am interested in fitting a slds to a multivariate timeseries to detect the hidden states sequence. I would be grateful if you could point me to a demo I could use as a template. I tried to run the "pyhsmm-slds-master\examples\demo.py" but could not make it to work (see my other post).