Home > Mateda2.0 > learning > LearnMOAModel.m

LearnMOAModel

PURPOSE ^

[model] = LearnMOAModel(k,NumbVar,Card,SelPop,AuxFunVal,learning_params)

SYNOPSIS ^

function [model] = LearnMOAModel(k,NumbVar,Card,SelPop,AuxFunVal,learning_params)

DESCRIPTION ^

 [model] = LearnMOAModel(k,NumbVar,Card,SelPop,AuxFunVal,learning_params)
 LearnMOAModel: The Markov network model learned by the Markov Optimization Algorithm (MOA) is learned
                The structure of the model can be given (see explanation of paramater Cliques below) or learned from
                the data. 
 INPUTS
 k: Current generation
 NumbVar: Number of variables
 Card: Vector with the dimension of all the variables. 
 SelPop:  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) = 
    Cliques: Structure of the model in a list of cliques that defines the neighborhood 
    Each row of Cliques is a clique. The first value is the number of neighbors 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
    When Cliques is empty, the model is learned from the data
 learning_params{1}(2) = Nneighbors: Constraint on the maximum number of
                         neighbors (similar to the maximum number of parents in a Bayesian network)
 learning_params{1}(3) = threshold 
                         threshold for determining the neighbors from the
                         matrix of the mutual information.
 learning_params{1}(4) = TypeAnnealing \in {'none','Boltzman_linear','fixed'}
                         Type of annealing method used to modify the way
                         the parameters of the model are computed
 learning_params{1}(5) = Temp: Temperature parameter for fixed temperature
 OUTPUTS
 model: Markov network model containing the structure (model{1} = Cliques)
        and the parameters (model{2} = Tables)

 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] = LearnMOAModel(k,NumbVar,Card,SelPop,AuxFunVal,learning_params)
0002 % [model] = LearnMOAModel(k,NumbVar,Card,SelPop,AuxFunVal,learning_params)
0003 % LearnMOAModel: The Markov network model learned by the Markov Optimization Algorithm (MOA) is learned
0004 %                The structure of the model can be given (see explanation of paramater Cliques below) or learned from
0005 %                the data.
0006 % INPUTS
0007 % k: Current generation
0008 % NumbVar: Number of variables
0009 % Card: Vector with the dimension of all the variables.
0010 % SelPop:  Population from which the model is learned
0011 % AuxFunVal: Evaluation of the data set (required for some learning algorithms, not for this one)
0012 % learning_params{1}(1) =
0013 %    Cliques: Structure of the model in a list of cliques that defines the neighborhood
0014 %    Each row of Cliques is a clique. The first value is the number of neighbors for variable i.
0015 %    The second, is the number of new variables (one new variable, i).
0016 %    Then, neighbor variables are listed and  finally new variables (variable i) are listed
0017 %    When Cliques is empty, the model is learned from the data
0018 % learning_params{1}(2) = Nneighbors: Constraint on the maximum number of
0019 %                         neighbors (similar to the maximum number of parents in a Bayesian network)
0020 % learning_params{1}(3) = threshold
0021 %                         threshold for determining the neighbors from the
0022 %                         matrix of the mutual information.
0023 % learning_params{1}(4) = TypeAnnealing \in {'none','Boltzman_linear','fixed'}
0024 %                         Type of annealing method used to modify the way
0025 %                         the parameters of the model are computed
0026 % learning_params{1}(5) = Temp: Temperature parameter for fixed temperature
0027 % OUTPUTS
0028 % model: Markov network model containing the structure (model{1} = Cliques)
0029 %        and the parameters (model{2} = Tables)
0030 %
0031 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0032  
0033 
0034 
0035 auxcell = learning_params{1}(1);
0036 if isemptycell(auxcell)
0037   Cliques =  [];   
0038 else
0039   Cliques = cell2num(learning_params{1}(1));
0040 end
0041 
0042 Nneighbors = cell2num(learning_params{1}(2)); 
0043 threshold = cell2num(learning_params{1}(3)); 
0044 TypeAnnealing = char(cellstr(learning_params{1}(4))); 
0045 Temp = cell2num(learning_params{1}(5)); 
0046 
0047    if isempty(Cliques)      
0048       % Univariate and Bivariate probabilities are learned
0049         [UnivProb,BivProb]= FindMargProb(SelPop,NumbVar,Card);
0050        
0051        % The Matrix of Mutual information is learned
0052          MI = IntMutualInfFromMargProb(NumbVar,Card,UnivProb,BivProb);
0053         
0054        % MIthreshold determines a threshold to consider variables "connected" in the Markov Network
0055          MIthreshold = threshold*(sum(sum(MI))/(NumbVar*(NumbVar-1))); % Average of the mutual information
0056         
0057        % The neighborhood structure is learned from the matrix of mutual information
0058          [Cliques] = FindNeighborhood(MI,Nneighbors,MIthreshold);
0059    end    
0060          % The conditional probability tables of each variable i given each
0061          % neighborhood are learned.
0062          
0063          [Tables]=LearnFDAParameters(Cliques,SelPop,NumbVar,Card);
0064            
0065          if ~strcmp(TypeAnnealing,'none')        
0066           if strcmp(TypeAnnealing,'Boltzman_linear')   % Boltzman probability with linear schedule
0067             Temp = 1/(0.5*k); 
0068           end
0069             for i=1:size(Tables,2)
0070              Tables{i} = exp(Tables{i}/Temp)./repmat(sum((exp(Tables{i}/Temp)'))',1,2);
0071             end
0072          end
0073         
0074      model{1} = Cliques;
0075      model{2} = Tables;
0076      
0077      return;
0078      
0079      
0080

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