markovmodel / PyEMMA

🚂 Python API for Emma's Markov Model Algorithms 🚂
http://pyemma.org
GNU Lesser General Public License v3.0
311 stars 119 forks source link

attribute error 'lag_observations' when coarse graining markov model (2.1rc2) #703

Closed clonker closed 8 years ago

clonker commented 8 years ago

PyEMMA version: 2.1rc2 bhmm version: 0.6.1

Executed code:

import pyemma.msm as msm
import numpy as np
dtrajs = np.random.randint(0, 4, 100)
M = msm.estimate_markov_model(dtrajs, 1)
print M
cg_msm = M.coarse_grain(3)
print cg_msm.P

Output:

MaximumLikelihoodMSM(connectivity='largest', count_mode='sliding',
           dt_traj='1 step', lag=1, maxerr=1e-08, maxiter=1000000,
           reversible=True, sparse=False, statdist_constraint=None)
23-02-16 14:59:53 pyemma.msm.estimators.maximum_likelihood_msm.MaximumLikelihoodMSM[3] WARNING  Requested coarse-grained model with 3 metastable states at lag=1.The ratio of relaxation timescales between 3 and 4 states is only 1.09279896364 while we recommend at least 1.5.  It is possible that the resulting HMM is inaccurate. Handle with caution.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-7ea018fbc74b> in <module>()
      4 M = msm.estimate_markov_model(dtrajs, 1)
      5 print M
----> 6 cg_msm = M.coarse_grain(3)
      7 print cg_msm.P

/Users/mho/miniconda/envs/py2k/lib/python2.7/site-packages/pyEMMA-2.1rc2-py2.7-macosx-10.5-x86_64.egg/pyemma/msm/estimators/maximum_likelihood_msm.pyc in coarse_grain(self, ncoarse, method)
    743             'nstates must be an int in [2,msmobj.nstates]'
    744 
--> 745         return self.hmm(ncoarse)
    746 
    747     ################################################################################

/Users/mho/miniconda/envs/py2k/lib/python2.7/site-packages/pyEMMA-2.1rc2-py2.7-macosx-10.5-x86_64.egg/pyemma/msm/estimators/maximum_likelihood_msm.pyc in hmm(self, nhidden)
    714         estimator = MaximumLikelihoodHMSM(lag=self.lagtime, nstates=nhidden, msm_init=self,
    715                                           reversible=self.is_reversible, dt_traj=self.dt_traj)
--> 716         estimator.estimate(self.discrete_trajectories_full)
    717         return estimator.model
    718 

/Users/mho/miniconda/envs/py2k/lib/python2.7/site-packages/pyEMMA-2.1rc2-py2.7-macosx-10.5-x86_64.egg/pyemma/_base/estimator.pyc in estimate(self, X, **params)
    342         if params:
    343             self.set_params(**params)
--> 344         self._model = self._estimate(X)
    345         self._estimated = True
    346         return self._model

/Users/mho/miniconda/envs/py2k/lib/python2.7/site-packages/pyEMMA-2.1rc2-py2.7-macosx-10.5-x86_64.egg/pyemma/msm/estimators/maximum_likelihood_hmsm.pyc in _estimate(self, dtrajs)
    191 
    192         # LAG AND STRIDE DATA
--> 193         dtrajs_lagged_strided = bhmm.lag_observations(dtrajs, self.lag, stride=self.stride)
    194 
    195         # OBSERVATION SET

AttributeError: 'module' object has no attribute 'lag_observations'
marscher commented 8 years ago

@franknoe the branch bhmm_fixes is not merged. Does this branch maybe contain the refactored code?

marscher commented 8 years ago

@clonker are you sure, that you really have bhmm-0.6.1, because I have this function here in this version.

clonker commented 8 years ago

Oh I am very sorry, for some reason I still had bhmm 0.5.3 installed in my conda environment! Closing this issue.

marscher commented 8 years ago

No problem!