首页 文章

如何使用sklearn HMM来计算观察数据的可能性

提问于
浏览
1

HMM有三个基本问题:

  • 给定模型参数和观测数据,估计隐藏状态的最佳序列 .

  • 给定模型参数和观测数据,计算数据的可能性 .

  • 仅给出观察到的数据,估计模型参数 .

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

1 回答

  • 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``.
    

相关问题