maxmouchet / HMMBase.jl

Hidden Markov Models for Julia.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example for multivariate features GMMHMM, include in docs

rbeeli opened this issue · comments

Hi,

do you have an example for a multivariate features Gaussian Mixture Model HMM, similar to GMMHMM from the hmmlearn Python package?
Extending the docs with such an example would help a lot.

Many thanks.

Hi,

This is currently unsupported out-of-the-box as the MixtureModel type from Distributions.jl does not implement fit_mle. Something like this could work:

using Distributions
using HMMBase

function Distributions.fit_mle(::Type{MixtureModel{Univariate, Continuous, Normal{Float64}, Categorical{Float64, Vector{Float64}}}}, x::Matrix, w::Vector)
    # Implement ML estimator here and return fitted mixture model.
end

A = [0.9 0.1; 0.1 0.9]
B = [
    MixtureModel([Normal(0, 1), Normal(1, 1)]),
    MixtureModel([Normal(10, 1), Normal(11, 1)])
]

hmm = HMM(A, B)
y = rand(hmm, 500)

fit_mle(hmm, y)