1
有對HMM模型的三個基本問題:如何使用sklearn HMM來計算觀測數據的可能性
- 鑑於模型參數和觀測數據,估計隱藏狀態的最優順序。
- 給定模型參數和觀測數據,計算數據的可能性。
- 僅給出觀察到的數據,估計模型參數。
問題1和問題3可以通過sklearn HMM tutorial來解決。但是,我們如何使用sklearn來解決問題2?
有對HMM模型的三個基本問題:如何使用sklearn HMM來計算觀測數據的可能性
問題1和問題3可以通過sklearn HMM tutorial來解決。但是,我們如何使用sklearn來解決問題2?
使用score()函數。來自代碼:
def score(self, X, lengths=None):
"""Compute the log probability under the model.
Parameters
----------
X : array-like, shape (n_samples, n_features)
Feature matrix of individual samples.
lengths : array-like of integers, shape (n_sequences,), optional
Lengths of the individual sequences in ``X``. The sum of
these should be ``n_samples``.
Returns
-------
logprob : float
Log likelihood of ``X``.