如何利用sklearn-HMM计算观测数据的似然性

2024-04-20 05:44:41 发布

您现在位置:Python中文网/ 问答频道 /正文

HMMs有三个基本问题:

  1. 在给定模型参数和观测数据的基础上,估计出最优隐状态序列。在
  2. 给定模型参数和观测数据,计算数据的似然性。在
  3. 根据观测数据,估计模型参数。在

问题1和问题3可以通过sklearn HMM tutorial来解决。但是我们如何使用sklearn来解决问题2呢?在


Tags: 数据模型参数状态序列sklearn基础tutorial
1条回答
网友
1楼 · 发布于 2024-04-20 05:44:41

使用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``.

相关问题 更多 >