Classify using GMM with MATLAB

喜你入骨 提交于 2019-12-08 10:42:54

问题


I want to perform classification of two classes using Gaussian Mixture Models with MATLAB.

I doing training by creating two models with the function gmdistribution.fit

NComponents = 1;
  for class=1:2
      model(class).obj =    gmdistribution.fit(trainData(class).feature,NComponents,'Regularize',.1);
  end

Then, given test data points, I want to know how to classify them. What I am doing now is to obtain the posterior probability for each point in each model:

vectorClasses = zeros(1,2);
    for class=1:2
        Pos=  posterior(model(class).obj,testDataPoint);           
         suma=0;
         for k=1:NComponents
             suma = suma + Pos(1,k)*model(class).obj.PComponents(k);
         end
        vectorClasses(class)=suma;
    end
    [v ix] = sort(vectorClasses,'descend');
    if ix(1)==realClass
        success= 1;
    else
        success= 0;
    end

I sum the multiplication of the posterior probability of each component and the probability of the component in the model. Then I sort the probabilities obtained in each model. I say the test data point correspond to the class with the highest probability.

Am I doing it ok? How is the correct way? Is there an easiest way to do it?


回答1:


seems that there is no need to have independent models per class as it would in the case of HMMs, as described in the answer in: this very complete description. Similar for the classification stage, posterior commands seems to do the work. However, it looks like the model does not indicate which cluster represents which class (we have to figure it out). If you have achieved a complete solution please post it. There isn't really much information on how to use matlab's gmm for classification (been searching too).



来源:https://stackoverflow.com/questions/24257192/classify-using-gmm-with-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!