Home > Mateda2.0 > learning > LearnMOAParameters.m

LearnMOAParameters

PURPOSE ^

[Tables] = LearnMOAParameters(Cliques,SelPop,NumbVar,Card)

SYNOPSIS ^

function[Tables] = LearnMOAParameters(Cliques,SelPop,NumbVar,Card)

DESCRIPTION ^

 [Tables] = LearnMOAParameters(Cliques,SelPop,NumbVar,Card)
 LearnMOAModel: The parameters of the Markov network model of the Markov Optimization Algorithm (MOA) 
                are learned from data
 INPUTS
    Cliques: Structure of the model in a list of cliques that defines the  
    Each row of Cliques is a clique. The first value is the number of neighbor for variable i. 
    The second, is the number of new variables (one new variable, i).
    Then, neighbor variables are listed and  finally new variables (variable i) are listed
 NumbVar: Number of variables
 Card: Vector with the dimension of all the variables. 
 SelPop:  Population from which the model is learned         
 OUTPUTS
 Tables: Probability tables for each variable conditioned on its neighbors

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function[Tables] = LearnMOAParameters(Cliques,SelPop,NumbVar,Card)
0002 % [Tables] = LearnMOAParameters(Cliques,SelPop,NumbVar,Card)
0003 % LearnMOAModel: The parameters of the Markov network model of the Markov Optimization Algorithm (MOA)
0004 %                are learned from data
0005 % INPUTS
0006 %    Cliques: Structure of the model in a list of cliques that defines the
0007 %    Each row of Cliques is a clique. The first value is the number of neighbor for variable i.
0008 %    The second, is the number of new variables (one new variable, i).
0009 %    Then, neighbor variables are listed and  finally new variables (variable i) are listed
0010 % NumbVar: Number of variables
0011 % Card: Vector with the dimension of all the variables.
0012 % SelPop:  Population from which the model is learned
0013 % OUTPUTS
0014 % Tables: Probability tables for each variable conditioned on its neighbors
0015 %
0016 % Last version 8/26/2008. Roberto Santana and Siddarta Shakya (roberto.santana@ehu.es)
0017 
0018 
0019 NumberCliques = size(Cliques,1);
0020 
0021 
0022 %%%%%%%%%%%%%%%%%%%%%%  First step  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 
0024 % The tables of all the cliques are filled
0025 
0026 
0027 for i=1:size(Cliques,1)
0028 
0029   sizeCliqOther = Cliques(i,2);
0030   sizeCliqSolap = Cliques(i,1);
0031 
0032   CliqOther = Cliques(i,Cliques(i,1)+3:Cliques(i,1)+Cliques(i,2)+2);
0033   AccCardOther = FindAccCard(sizeCliqOther,Card(CliqOther));
0034   dimOther =   NumconvertCard(Card(CliqOther)-1,sizeCliqOther,AccCardOther)+1;
0035 
0036   if(sizeCliqSolap > 0)
0037     CliqSolap = Cliques(i,3:(Cliques(i,1)+2));
0038     AccCardSolap = FindAccCard(sizeCliqSolap,Card(CliqSolap));
0039     dimSolap =   NumconvertCard(Card(CliqSolap)-1,sizeCliqSolap,AccCardSolap)+1;
0040     aux=zeros(dimSolap,dimOther);
0041   else 
0042     AccCardSolap = [];
0043     CliqSolap = [];
0044     aux=zeros(1,dimOther);
0045     dimSolap = 1;
0046   end
0047    
0048   AllVars = [CliqSolap,CliqOther];
0049 
0050  
0051  for j=1:dimSolap
0052     if (sizeCliqSolap>0) 
0053       solapval = IndexconvertCard(j-1,sizeCliqSolap,AccCardSolap);
0054     else
0055       solapval=[];
0056     end
0057 
0058     for k=1:dimOther
0059      auxSelPop=SelPop(:,[CliqSolap,CliqOther]);
0060      otherval =  IndexconvertCard(k-1,sizeCliqOther,AccCardOther);
0061      allvarvalues = [solapval,otherval];
0062     
0063      if(size(allvarvalues,2)==1)
0064        aux(j,k) =  sum((auxSelPop==repmat(allvarvalues,size(SelPop,1),1))');
0065      else 
0066        aux(j,k)=sum( sum((auxSelPop==repmat(allvarvalues,size(SelPop,1),1))') == size(allvarvalues,2)); 
0067      end
0068     end 
0069    % aux(j,:) = (aux(j,:))/(sum(aux(j,:)));
0070     aux(j,:) = (aux(j,:)+1)/(sum(aux(j,:))+dimOther); % Laplace Estimator
0071   end
0072  %aux=aux/sum(sum(aux)); % Normalization
0073  
0074  
0075  % En Table i se guardan las probabilidades del clique i
0076 
0077  eval(['Tables{',num2str(i),'}=aux;']);
0078          
0079 end
0080

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