Closed giadasp closed 4 years ago
I think you're missing initialization of the Gaussians, your constructor initializes with 0's and identity covariance, and em!
is not going to be able to separate these identical mixtures. So usually you initialize the components using something like k-means.
The trick here is to use the training constructor:
gmm = GMM(3, X, nIter=10)
which does the k-means, followed by EM for you.
Thank you for the prompt reply, I have this error with nIter=10
ERROR: MethodError: no method matching GMM(::Array{Float64,2}, ::Int64; kind=:full, nIter=10)
Closest candidates are:
GMM(::Int64, ::Int64; kind) at C:\Users\...\.julia\packages\GaussianMixtures\3jRIL\src\gmms.jl:12 got unsupported keyword argument "nIter"
and this one without
ERROR: MethodError: no method matching GMM(::Array{Float64,2}, ::Int64; kind=:full)
Closest candidates are:
GMM(::Int64, ::Int64; kind) at C:\Users\...\.julia\packages\GaussianMixtures\3jRIL\src\gmms.jl:12
GMM(::Union{Array{T,2}, Data{T,VT} where VT<:Union{AbstractString, Array{T,2} where T}}; kind) where T<:AbstractFloat at C:\Users\...\.julia\packages\GaussianMixtures\3jRIL\src\train.jl:11
Sorry that should be
gmm = GMM(3, X, nIter=10)
All right! Now it works :)
Dear David,
I'm trying to fit a bivariate Gaussian mixture with 3 components to my data. The issue is that the resulting components are all equal (same mean vector and var/covar matrix), also the three weights are equal. I've initiliazed the gmm with
gmm=GMM(3,2;kind=:full)
and then I trained it byem!(gmm,X,nIter=10)
I saw in the history that is converging. myX
is 2000x2. Am I doing anything wrong? Thank you in advance for your support.Giada