redress
redress

Reputation: 1439

Sequence of Predictions from HMMLearn

Im working along with this documentation, but I can't figure out how to extract the sequence of predictions from the test data.

I have trained the model with .fit(X_train), but the following:

unseen_hidden_states = model.predict(X_test)

Returns an array:

[2 1 1 ..., 3 3 3]

Which I dont know how to interpret or how to extract the predicted sequence from

Upvotes: 0

Views: 1684

Answers (1)

Eskapp
Eskapp

Reputation: 3635

As stated in the documentation:

The inferred optimal hidden states can be obtained by calling the predict method.

A results such as [2, 1, 1, 3] for a sequence X_test = [x1, x2, x3, x4] means that x1 has most probably be generated by the hidden state 2, x2 by the hidden state 1, x3 by the hidden state 1, and x4 by the hidden state 3.

If you want to read about the algorithm behind this, you can look for the Viterbi algorithm.

EDIT:

If you are looking for computing the likelihood of the data with respect to the model, you should have a look to the functions score, _compute_log_likelihood, or score_samples.

Upvotes: 1

Related Questions