开发者

Expectation Maximization in Matlab on Missing Data

开发者 https://www.devze.com 2023-04-02 12:05 出处:网络
I have to use EM to estimate the mean and covariance of the Gaussian distribution for each of the two classes. They have some missing attributes too.开发者_运维问答

I have to use EM to estimate the mean and covariance of the Gaussian distribution for each of the two classes. They have some missing attributes too.开发者_运维问答

Classes of each object is known. Therefore the problem basically reduces to fitting a gaussian model with missing element.

Which is the best library to use?

How is ECM Algorithm different from EM algorithm?


If you have access to the Statistics Toolbox, you can use the GMDISTRIBUTION class to fit a Gaussian Mixture Model using the EM algorithm.

Here is an example:

%# sample dataset
load fisheriris
data = meas(:,1:2);
label = species;

%# fit GMM using EM
K = 2;
obj = gmdistribution.fit(data, K);

%# assign points to mixtures: argmax_k P(M(k)|data)
P = posterior(obj, data);
[~,mIDX] = max(P,[],2);

%# GMM components
obj.mu             %# means
obj.Sigma          %# covariances
obj.PComponents    %# mixture weights

%# visualize original data clusters
figure
gscatter(data(:,1), data(:,2), label)

%# visualize mixtures found
figure
gscatter(data(:,1), data(:,2), mIDX), hold on
ezcontour(@(x,y)pdf(obj,[x y]), xlim(), ylim())

Expectation Maximization in Matlab on Missing Data

If not, check out the excellent Netlab Toolbox, as it has GMM implementation.


Thanks all.But I am using ecmnmle for estimating parameters and then obtaining distribution of marginals which is used later in bayes classification. It works pretty fine with accuracies of 0.9 and 0.69 on 2 classes.


Please take a look at the PMTK toolkit

Here is the EM implementation (Fit a mixture of Gaussians where the data may have NaN entries)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号