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)
如果我想从.TXT
文档中读取观察到的内容而不是手动输入,例如 ('red', 'red','write'),该怎么办?