Home > gmmbayestb-v1.0 > gmmb_create.m

gmmb_create

PURPOSE ^

GMMB_CREATE - Construct new Bayesian classifier with Gaussian mixture model pdf

SYNOPSIS ^

function [bayesS, varargout] = gmmb_create(data, cl, method, varargin);

DESCRIPTION ^

GMMB_CREATE - Construct new Bayesian classifier with Gaussian mixture model pdf

     S = GMMB_CREATE(data, class, method [, parameters]) Generates a
     Bayesian classifier for one or several classes having GMM
     distribution with estimated mean values, variances and
     apriories. Classifier is returned in bayesS struct S.

     method can be 'EM', 'FJ' or 'GEM'.
       EM and FJ can work with complex numbers.

     See also readme.txt, GMMB_HIST, GMMB_GENERATEHIST.

     Parameters are delegated directly to underlaying GMM estimation
     function (gmmb_em, gmmb_fj, gmmb_gem). See also them.

 Examples:
   bayesS = gmmb_create(data, class, 'EM', 'components', 5, 'thr', 1e-8);
   bayesS = gmmb_create(data, class, 'FJ', 'Cmax', 50, 'thr', 1e-9);
   bayesS = gmmb_create(data, class, 'GEM', 'Cmax', 10, 'verbose', true);

   The bayesS struct is documented in readme.txt.

 References:
   [1] Duda, R.O., Hart, P.E, Stork, D.G, Pattern Classification,
   2nd ed., John Wiley & Sons, Inc., 2001.

 Author(s):
    Joni Kamarainen <Joni.Kamarainen@lut.fi>
    Pekka Paalanen <pekka.paalanen@lut.fi>

 Copyright:

   Bayesian Classifier with Gaussian Mixture Model Pdf is
   Copyright (C) 2003, 2004 by Pekka Paalanen and Joni-Kristian
   Kamarainen.

   $Name:  $ $Revision: 1.1 $  $Date: 2004/11/02 08:32:22 $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %GMMB_CREATE - Construct new Bayesian classifier with Gaussian mixture model pdf
0002 %
0003 %     S = GMMB_CREATE(data, class, method [, parameters]) Generates a
0004 %     Bayesian classifier for one or several classes having GMM
0005 %     distribution with estimated mean values, variances and
0006 %     apriories. Classifier is returned in bayesS struct S.
0007 %
0008 %     method can be 'EM', 'FJ' or 'GEM'.
0009 %       EM and FJ can work with complex numbers.
0010 %
0011 %     See also readme.txt, GMMB_HIST, GMMB_GENERATEHIST.
0012 %
0013 %     Parameters are delegated directly to underlaying GMM estimation
0014 %     function (gmmb_em, gmmb_fj, gmmb_gem). See also them.
0015 %
0016 % Examples:
0017 %   bayesS = gmmb_create(data, class, 'EM', 'components', 5, 'thr', 1e-8);
0018 %   bayesS = gmmb_create(data, class, 'FJ', 'Cmax', 50, 'thr', 1e-9);
0019 %   bayesS = gmmb_create(data, class, 'GEM', 'Cmax', 10, 'verbose', true);
0020 %
0021 %   The bayesS struct is documented in readme.txt.
0022 %
0023 % References:
0024 %   [1] Duda, R.O., Hart, P.E, Stork, D.G, Pattern Classification,
0025 %   2nd ed., John Wiley & Sons, Inc., 2001.
0026 %
0027 % Author(s):
0028 %    Joni Kamarainen <Joni.Kamarainen@lut.fi>
0029 %    Pekka Paalanen <pekka.paalanen@lut.fi>
0030 %
0031 % Copyright:
0032 %
0033 %   Bayesian Classifier with Gaussian Mixture Model Pdf is
0034 %   Copyright (C) 2003, 2004 by Pekka Paalanen and Joni-Kristian
0035 %   Kamarainen.
0036 %
0037 %   $Name:  $ $Revision: 1.1 $  $Date: 2004/11/02 08:32:22 $
0038 %
0039 
0040 function [bayesS, varargout] = gmmb_create(data, cl, method, varargin);
0041 
0042 K = max(cl);
0043 
0044 mu ={};
0045 sigma = {};
0046 weight = {};
0047 prior = {};
0048 stats = {};
0049 
0050 for k = 1:K
0051     cvals = data(cl == k, :);
0052     N = size(cvals,1);    % points
0053     
0054     switch method
0055     case 'EM'
0056         [estim stat] = gmmb_em(cvals, varargin{:});
0057     case 'FJ'
0058         [estim stat] = gmmb_fj(cvals, varargin{:});
0059     case 'GEM'
0060         [estim stat] = gmmb_gem(cvals, varargin{:});
0061     otherwise
0062         error('Unknown method');
0063     end
0064 
0065     mu{k} = estim.mu;
0066     sigma{k} = estim.sigma;
0067     weight{k} = estim.weight;
0068     prior{k} = N/size(data,1);
0069     stats{k} = stat;
0070 end
0071 
0072 bayesS = struct('mu', mu,...
0073         'sigma', sigma,...
0074         'apriories', prior,...
0075         'weight', weight);
0076 
0077 if nargout > 1
0078     varargout{1} = stats;
0079 end
0080

Generated on Thu 14-Apr-2005 13:50:22 by m2html © 2003