May 2018
Intermediate to advanced
576 pages
14h 42m
English
At this point, we can continue with the previous example, using our model to find the most likely hidden state sequence given a set of possible observations. We can use either the decode() method or the predict() method. The first one returns the log probability of the whole sequence and the sequence itself; however, they all use the Viterbi algorithm as a default decoder:
sequence = np.array([[1], [1], [1], [0], [1], [1], [1], [0], [1], [0], [1], [0], [1], [0], [1], [1], [0], [1], [1], [0], [1], [0], [1], [0], [1], [0], [1], [1], [1], [0], [0], [1], [1], [0], [1], [1]], dtype=np.int32)lp, hs = hmm_model.decode(sequence)print(hs)[0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 ...
Read now
Unlock full access