Put the contents of the TXT document into the HMM as observations

58 Views Asked by At
if __name__ == "__main__":
A = np.random.random([3,3])
B = np.random.random([3,2])
pi = np.random.random(3)

hmm = HMM(pi, A, B)
observation = ['red','write']
# here I need input some observation to the HMM model to predict the Original model parameters

observed = ['red', 'write','write','write','write','write','red','write','red','red','write','write','red','write','red'
           ]
A,B,pi = baum_welch(hmm, observed)

print('state transition probability matrix A:\n', A)
print('observation probability matrix B:\n', B)
print('initial state probability vector pi:\n', pi)

What to do if I want to read the observed content from a .TXT document instead of the manual input, like ('red', 'red','write')?

0

There are 0 best solutions below