Home > Mateda2.0 > learning > LearnMixtureofFullGaussianModels.m

LearnMixtureofFullGaussianModels

PURPOSE ^

[model] = LearnMixtureofFullGaussianModels(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)

SYNOPSIS ^

function [model] = LearnMixtureofFullGaussianModels(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)

DESCRIPTION ^

 [model] =  LearnMixtureofFullGaussianModels(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)
 LearnMixtureofFullGaussianModels:     Learns a mixture of full
 multivariate Gaussian models using clustering
 INPUTS
 k: Current generation
 NumbVar: Number of variables
 Card: Vector with the range of values for all the variables. 
 AuxPop:  Population from which the model is learned  
 AuxFunVal:   Evaluation of the data set (required for some learning algorithms, not for this one)
 learning_params{1}(1) = what_to_cluster: Information used to cluster the
                         solutions: 'vars': information about variables values, 'objs': objective
                         values, 'vars_and_objs': objectives and variables are clustered together
 learning_params{1}(2) = how_to_cluster: Method used to cluster the
 solutions, currently: 'ClusterPointsAffinity' and 'ClusterPointsKmeans'
 learning_params{1}(3) = nclusters: Number of clusters 
 learning_params{1}(4) = distance: Distance used for clustering (e.g.
                         'euclidean', 'correlation', 'cosine' ... See help pdist for full list of
                          possible metrics)
 learning_params{1}(5) = normalization: Whether the values of the variables
                                    are normalized previous to clustering. This is done in order to avoid
                                    that some variables have more weights in the clustering.% OUTPUTS
 model: model{1,i} = mean of the variables for solutions in  cluster i
        model{2,i} = covariance of the variables for solutions in cluster i
        model{3,i} = size(ind,1)/PopSize;    % Coefficient of component i

 Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [model] = LearnMixtureofFullGaussianModels(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)
0002 % [model] =  LearnMixtureofFullGaussianModels(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)
0003 % LearnMixtureofFullGaussianModels:     Learns a mixture of full
0004 % multivariate Gaussian models using clustering
0005 % INPUTS
0006 % k: Current generation
0007 % NumbVar: Number of variables
0008 % Card: Vector with the range of values for all the variables.
0009 % AuxPop:  Population from which the model is learned
0010 % AuxFunVal:   Evaluation of the data set (required for some learning algorithms, not for this one)
0011 % learning_params{1}(1) = what_to_cluster: Information used to cluster the
0012 %                         solutions: 'vars': information about variables values, 'objs': objective
0013 %                         values, 'vars_and_objs': objectives and variables are clustered together
0014 % learning_params{1}(2) = how_to_cluster: Method used to cluster the
0015 % solutions, currently: 'ClusterPointsAffinity' and 'ClusterPointsKmeans'
0016 % learning_params{1}(3) = nclusters: Number of clusters
0017 % learning_params{1}(4) = distance: Distance used for clustering (e.g.
0018 %                         'euclidean', 'correlation', 'cosine' ... See help pdist for full list of
0019 %                          possible metrics)
0020 % learning_params{1}(5) = normalization: Whether the values of the variables
0021 %                                    are normalized previous to clustering. This is done in order to avoid
0022 %                                    that some variables have more weights in the clustering.% OUTPUTS
0023 % model: model{1,i} = mean of the variables for solutions in  cluster i
0024 %        model{2,i} = covariance of the variables for solutions in cluster i
0025 %        model{3,i} = size(ind,1)/PopSize;    % Coefficient of component i
0026 %
0027 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0028  
0029 what_to_cluster = char(cellstr(learning_params{1}(1)));
0030 how_to_cluster =  char(cellstr(learning_params{1}(2)));
0031 nclusters = cell2num(learning_params{1}(3));
0032 distance = char(cellstr(learning_params{1}(4)));
0033 normalization = cell2num(learning_params{1}(5));
0034 
0035 PopSize = size(AuxPop,1);
0036 
0037  switch what_to_cluster
0038             case 'vars', NormPop = AuxPop;
0039             case 'objs', NormPop = AuxFunVal; 
0040             case 'vars_and_objs',   NormPop = [AuxPop,AuxFunVal];
0041  end,        
0042 
0043 
0044 if normalization==1
0045  for i=1:size(NormPop,2),
0046   NormPop(:,i) = normalize(NormPop(:,i));   % First values for all the variables are normalized
0047  end
0048 end
0049 
0050 
0051  [ind,nclusters] = eval([how_to_cluster,'(NormPop,distance,nclusters);']);
0052  
0053  
0054  for i=1:nclusters,   
0055    idx = find(ind==i);
0056    nmembers = size(idx,1);
0057    if nmembers>1,
0058     model{1,i} =  mean(AuxPop(idx,:));   % Vector of means for each cluster
0059     model{2,i} =  cov(AuxPop(idx,:));    % Vector of covariances for each cluster
0060     model{3,i} =  nmembers/PopSize;    % Coefficient for the mixture, proportional to the number of points in the cluster
0061    else
0062     model{1,i} =  mean(AuxPop);   % Vector of means for each cluster
0063     model{2,i} =  cov(AuxPop);    % Vector of covariances for each cluster
0064     model{3,i} =  nmembers/PopSize;    % Coefficient for the mixture, proportional to the number of points in the cluster
0065    end
0066  end
0067  return;
0068        
0069        
0070

Generated on Fri 04-Dec-2009 13:38:29 by m2html © 2003