Skip to content
Snippets Groups Projects
Commit 3ba405ec authored by Scott Linderman's avatar Scott Linderman
Browse files

python 3 imports

parent 6c831346
No related branches found
No related tags found
No related merge requests found
...@@ -605,20 +605,20 @@ class HMMStatesEigen(HMMStatesPython): ...@@ -605,20 +605,20 @@ class HMMStatesEigen(HMMStatesPython):
@staticmethod @staticmethod
def _messages_backwards_log(trans_matrix,log_likelihoods): def _messages_backwards_log(trans_matrix,log_likelihoods):
from hmm_messages_interface import messages_backwards_log from pyhsmm.internals.hmm_messages_interface import messages_backwards_log
return messages_backwards_log( return messages_backwards_log(
trans_matrix,log_likelihoods, trans_matrix,log_likelihoods,
np.empty_like(log_likelihoods)) np.empty_like(log_likelihoods))
@staticmethod @staticmethod
def _messages_forwards_log(trans_matrix,init_state_distn,log_likelihoods): def _messages_forwards_log(trans_matrix,init_state_distn,log_likelihoods):
from hmm_messages_interface import messages_forwards_log from pyhsmm.internals.hmm_messages_interface import messages_forwards_log
return messages_forwards_log(trans_matrix,log_likelihoods, return messages_forwards_log(trans_matrix,log_likelihoods,
init_state_distn,np.empty_like(log_likelihoods)) init_state_distn,np.empty_like(log_likelihoods))
@staticmethod @staticmethod
def _messages_forwards_normalized(trans_matrix,init_state_distn,log_likelihoods): def _messages_forwards_normalized(trans_matrix,init_state_distn,log_likelihoods):
from hmm_messages_interface import messages_forwards_normalized from pyhsmm.internals.hmm_messages_interface import messages_forwards_normalized
return messages_forwards_normalized(trans_matrix,log_likelihoods, return messages_forwards_normalized(trans_matrix,log_likelihoods,
init_state_distn,np.empty_like(log_likelihoods)) init_state_distn,np.empty_like(log_likelihoods))
...@@ -640,19 +640,19 @@ class HMMStatesEigen(HMMStatesPython): ...@@ -640,19 +640,19 @@ class HMMStatesEigen(HMMStatesPython):
@staticmethod @staticmethod
def _sample_forwards_log(betal,trans_matrix,init_state_distn,log_likelihoods): def _sample_forwards_log(betal,trans_matrix,init_state_distn,log_likelihoods):
from hmm_messages_interface import sample_forwards_log from pyhsmm.internals.hmm_messages_interface import sample_forwards_log
return sample_forwards_log(trans_matrix,log_likelihoods, return sample_forwards_log(trans_matrix,log_likelihoods,
init_state_distn,betal,np.empty(log_likelihoods.shape[0],dtype='int32')) init_state_distn,betal,np.empty(log_likelihoods.shape[0],dtype='int32'))
@staticmethod @staticmethod
def _sample_backwards_normalized(alphan,trans_matrix_transpose): def _sample_backwards_normalized(alphan,trans_matrix_transpose):
from hmm_messages_interface import sample_backwards_normalized from pyhsmm.internals.hmm_messages_interface import sample_backwards_normalized
return sample_backwards_normalized(trans_matrix_transpose,alphan, return sample_backwards_normalized(trans_matrix_transpose,alphan,
np.empty(alphan.shape[0],dtype='int32')) np.empty(alphan.shape[0],dtype='int32'))
@staticmethod @staticmethod
def _resample_multiple(states_list): def _resample_multiple(states_list):
from hmm_messages_interface import resample_normalized_multiple from pyhsmm.internals.hmm_messages_interface import resample_normalized_multiple
if len(states_list) > 0: if len(states_list) > 0:
loglikes = resample_normalized_multiple( loglikes = resample_normalized_multiple(
states_list[0].trans_matrix,states_list[0].pi_0, states_list[0].trans_matrix,states_list[0].pi_0,
...@@ -666,7 +666,7 @@ class HMMStatesEigen(HMMStatesPython): ...@@ -666,7 +666,7 @@ class HMMStatesEigen(HMMStatesPython):
def _expected_statistics_from_messages( def _expected_statistics_from_messages(
trans_potential,likelihood_log_potential,alphal,betal, trans_potential,likelihood_log_potential,alphal,betal,
expected_states=None,expected_transcounts=None): expected_states=None,expected_transcounts=None):
from hmm_messages_interface import expected_statistics_log from pyhsmm.internals.hmm_messages_interface import expected_statistics_log
expected_states = np.zeros_like(alphal) \ expected_states = np.zeros_like(alphal) \
if expected_states is None else expected_states if expected_states is None else expected_states
expected_transcounts = np.zeros_like(trans_potential) \ expected_transcounts = np.zeros_like(trans_potential) \
...@@ -678,7 +678,7 @@ class HMMStatesEigen(HMMStatesPython): ...@@ -678,7 +678,7 @@ class HMMStatesEigen(HMMStatesPython):
### Vitberbi ### Vitberbi
def Viterbi(self): def Viterbi(self):
from hmm_messages_interface import viterbi from pyhsmm.internals.hmm_messages_interface import viterbi
self.stateseq = viterbi(self.trans_matrix,self.aBl,self.pi_0, self.stateseq = viterbi(self.trans_matrix,self.aBl,self.pi_0,
np.empty(self.aBl.shape[0],dtype='int32')) np.empty(self.aBl.shape[0],dtype='int32'))
......
...@@ -500,7 +500,7 @@ class HSMMStatesEigen(HSMMStatesPython): ...@@ -500,7 +500,7 @@ class HSMMStatesEigen(HSMMStatesPython):
def messages_backwards(self): def messages_backwards(self):
# NOTE: np.maximum calls are because the C++ code doesn't do # NOTE: np.maximum calls are because the C++ code doesn't do
# np.logaddexp(-inf,-inf) = -inf, it likes nans instead # np.logaddexp(-inf,-inf) = -inf, it likes nans instead
from hsmm_messages_interface import messages_backwards_log from pyhsmm.internals.hsmm_messages_interface import messages_backwards_log
betal, betastarl = messages_backwards_log( betal, betastarl = messages_backwards_log(
np.maximum(self.trans_matrix,1e-50),self.aBl,np.maximum(self.aDl,-1000000), np.maximum(self.trans_matrix,1e-50),self.aBl,np.maximum(self.aDl,-1000000),
self.aDsl,np.empty_like(self.aBl),np.empty_like(self.aBl), self.aDsl,np.empty_like(self.aBl),np.empty_like(self.aBl),
...@@ -519,7 +519,7 @@ class HSMMStatesEigen(HSMMStatesPython): ...@@ -519,7 +519,7 @@ class HSMMStatesEigen(HSMMStatesPython):
return super(HSMMStatesEigen,self).messages_backwards() return super(HSMMStatesEigen,self).messages_backwards()
def sample_forwards(self,betal,betastarl): def sample_forwards(self,betal,betastarl):
from hsmm_messages_interface import sample_forwards_log from pyhsmm.internals.hsmm_messages_interface import sample_forwards_log
if self.left_censoring: if self.left_censoring:
raise NotImplementedError raise NotImplementedError
caBl = np.vstack((np.zeros(betal.shape[1]),np.cumsum(self.aBl[:-1],axis=0))) caBl = np.vstack((np.zeros(betal.shape[1]),np.cumsum(self.aBl[:-1],axis=0)))
...@@ -533,7 +533,7 @@ class HSMMStatesEigen(HSMMStatesPython): ...@@ -533,7 +533,7 @@ class HSMMStatesEigen(HSMMStatesPython):
@staticmethod @staticmethod
def _resample_multiple(states_list): def _resample_multiple(states_list):
from hsmm_messages_interface import resample_log_multiple from pyhsmm.internals.hsmm_messages_interface import resample_log_multiple
if len(states_list) > 0: if len(states_list) > 0:
Ts = [s.T for s in states_list] Ts = [s.T for s in states_list]
longest = np.argmax(Ts) longest = np.argmax(Ts)
......
from __future__ import division from __future__ import division
import numpy as np import numpy as np
from matplotlib import pyplot as plt from matplotlib import pyplot as plt
from stats import cov
from pyhsmm.util.stats import cov
def plot_gaussian_2D(mu, lmbda, color='b', centermarker=True,label='',alpha=1.,ax=None,artists=None): def plot_gaussian_2D(mu, lmbda, color='b', centermarker=True,label='',alpha=1.,ax=None,artists=None):
''' '''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment