Username Remember Me?
Password   forgot password?
   
   
Problem using mixture of gaussians (gaussm)
Posted: 19 December 2008 06:03 PM   [ Ignore ]  
Jr. Member
RankRank
Total Posts:  41
Joined  2008-07-11

Hi everybody. I am working with mixture of gaussians models for multi-class classification and found that these models always maps from ‘k’ to 1 being k the number of features in the dataset. This can be seen in the example “prex_mcplot.m” comparing the trained mapping:

w = qdc(A)
Bayes-Normal-2, 2 to 4 trained mapping --> normal_map

for example with:

w2 = gaussm(A,3)
Mixture of Gaussians, 2 to 1 trained mapping --> sequential

And if I try:

confmat(A*w)

True | Estimated Labels
Labels | 1 2 3 4 | Totals
--------|----------------------------|-------
1 | 19 1 0 0 | 20
2 | 0 20 0 0 | 20
3 | 0 0 20 0 | 20
4 | 0 0 0 20 | 20
--------|----------------------------|-------
Totals | 19 21 20 20 | 80

while if I try:

confmat(A*w2)

True | Estimated Labels
Labels | 4-clas| Totals
--------|-------|-------
1 | 20 | 20
2 | 20 | 20
3 | 20 | 20
4 | 20 | 20
--------|-------|-------
Totals | 80 | 80

Am I missunderstanding something or this is not working as it should ?

Thanks in advance!
Mariano

Profile
 
 
Posted: 19 December 2008 06:26 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  236
Joined  2008-04-26

Dear Mariano,

there is one important difference between qdc and gaussm. While qdc is a classifier and therefore outputs one value for each class, the gaussm is a density estimator and thus it yields only single output. For multi-class datasets, gaussm still estimates one model per class but then mixes the per-class outputs using class-priors into a single density result.

You can look into the trained mapping:

>> w2 gaussm(b,3)
Mixture of Gaussians2 to 1 trained  mapping   --> sequential

internal data for the mappinga sequence of the density estimator mapping and affine mapping:
>> +
w2
ans 

    
[2x4 mapping]    [4x1 mapping]

looking into the first mappingit's a stack of four per-class trained estimators:
>> w2{1}
2 to 4 trained  mapping   --> stacked
>> +w2{1}
ans = 
    [2x1 mapping]    [2x1 mapping]    [2x1 mapping]    [2x1 mapping]

% the internals of the affine mapping:
>> w2{2}
4 to 1 trained  mapping   --> affine
>> t=+w2{2}
t = 
           rot: [4x1 double]
        offset: 0
    lablist_in: [4x1 double]
% the mixing proportions (priors):
>> t.rot
ans =
    0.2377
    0.2652
    0.2692
    0.2279

Hope it helps,

Pavel

Profile
 
 
Posted: 19 December 2008 07:21 PM   [ Ignore ]   [ # 2 ]  
Jr. Member
RankRank
Total Posts:  41
Joined  2008-07-11

Thanks for the fast response Pavel, but how is the model supposed to be used as a classifier ? I mean how does it map a class output (or an a posteriori probability) from the dataset features.

Thanks again,
Mariano.

Profile
 
 
Posted: 19 December 2008 09:12 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRank
Total Posts:  236
Joined  2008-04-26

Dear Mariano,

if you’d like to use mixture of Gaussians as a classifier instead of a QDC with a single Gaussian per class, then use the mogc mapping, not gaussm.
The mogc classifier will estimate a separate mixture model for each of the classes using EM algorithm.

By convention, the names of PRTools classifiers end with c (fisherc, qdc, mogc, perlc, ...). While mappings convert their input to arbitrary number of output dimensions, classifiers provide one output per class. These per-class outputs may be then converted using labeld into crisp labels.  Only classifiers (ending with c) make this conversion possible as they fill the class names into the feature labels (column names) of the output dataset.

On the other hand, gaussm is only a density estimator using a mixture model, not a classifier.  It does not assign the class names into the feature labels of the processed dataset. If you try to use the first stage in the w2 sequential mapping above on a new dataset, it will also provide four outputs, but not the correct class names:

>> v=w2{1}
2 to 4 trained  mapping   
--> stacked
>> out=b*v
Multi
-Class Problem501 by 4 dataset with 4 classes[139  129  126  107]
>> getfeatlab(out)
ans =
Multi-Class Problem
Multi
-Class Problem
Multi
-Class Problem
Multi
-Class Problem

Does it help?

Pavel

Profile
 
 
Posted: 22 December 2008 09:45 AM   [ Ignore ]   [ # 4 ]  
Jr. Member
RankRank
Total Posts:  41
Joined  2008-07-11

Yes, a lot ! :)

Thank you very much Pavel.
Mariano.

Profile