I'm getting the following error when I run the train.hmm()
ValueError: operands could not be broadcast together with shapes (7,20) (1,7)
I know what a broadcast error is and went through the docs. But I cannot change dimensions of the matrix as it will pop an error in another place. The code is as given below.
start_probability = np.matrix( '0.5 0.02 0.18 0.05 0.01 0.2 0.04 ')
transition_probability = np.matrix('0.9 0.012 0.012 0.012 0.002 0.05 0.012 \
; 0.03 0.35 0.05 0.05 0.02 0.45 0.05 \
; 0.03 0.05 0.45 0.05 0.02 0.35 0.05 \
; 0.1 0.1 0.1 0.4 0.1 0.1 0.1 \
; 0.1 0.1 0.1 0.1 0.4 0.1 0.1 \
; 0.2 0.05 0.05 0.05 0.05 0.4 0.2 \
; 0.12 0.12 0.12 0.12 0.01 0.12 0.39')
emission_probability = np.matrix(np.ones((7, 20)) * 0.05)
test = hmm(states,possible_observation,start_probability,transition_probability,emission_probability)
observations = ['A', 'S','T','A']
obs4 = ['C', 'A','G']
observation_tuple = []
observation_tuple.extend( [observations,obs4] )
quantities_observations = [10, 20]
num_iter=1000
e,t,s = test.train_hmm(observation_tuple,num_iter,quantities_observations)
The error corresponds to the last line. If I transpose the start_prbability or emission_probability matrix, I'll get an error in the test = hmm() line itself.
What am I doing wrong here?