Home > Mateda2.0 > knowledge_extraction > visualization > ReadBNStructures.m

ReadBNStructures

PURPOSE ^

[run_structures,maxgen,nruns] = ReadBNStructures(n, maxgen,

SYNOPSIS ^

function[run_structures,maxgen,nruns] = ReadBNStructures(n, maxgen, nruns,AllModels)

DESCRIPTION ^

 [run_structures,maxgen,nruns] = ReadBNStructures(n, maxgen,
 nruns,AllModels)
 ReadBNStructures:   Given the BN models learned during the execution of
                     Mateda (saved in Cache{k,:}. Extract information
                     ready for analysis and visualization
 INPUTS
 n: Number of variables
 mangen: maximum number of generations
 nruns: number of runs of the algorithm
 AllModels: Cell array containing in each row all the BN models saved during
            one run of LearnBN, i.e. AllModels{i} = Cache{3,:} where Cache
            is the output of the EDA that learns BNs
 OUTPUTS
 run_structures{1} = indexmatrix(n,n): Associates an index to each possible edge in the network.
 e.g. indexmatrix(1,2) = 1, number of edges m = n*(n+1)/2;
 run_structures{2} = AllBigMatrices{nruns}(m,maxgen}: For each run contains whether the edge i appeared in generation j
 run_structures{3} = AllSumMatrices(m,maxgen): = \sum_i^nruns AllBigMatrices{i},
 i.e. the number of runs that each edge i appeared in generation j 
 run_structures{4} = AllContactMatrix{maxgen}(n,n): The number of runs in which edge i,j
 was present in generation k.
 run_structures{5} = SumAllContactMatrix(n,n): = \sum_k^maxgen AllContactMatrix{k}. 
 i.e. Total number of times edge i,j was present in all the structures
 learned in all generations of all runs.

 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[run_structures,maxgen,nruns] = ReadBNStructures(n, maxgen, nruns,AllModels)
0002 % [run_structures,maxgen,nruns] = ReadBNStructures(n, maxgen,
0003 % nruns,AllModels)
0004 % ReadBNStructures:   Given the BN models learned during the execution of
0005 %                     Mateda (saved in Cache{k,:}. Extract information
0006 %                     ready for analysis and visualization
0007 % INPUTS
0008 % n: Number of variables
0009 % mangen: maximum number of generations
0010 % nruns: number of runs of the algorithm
0011 % AllModels: Cell array containing in each row all the BN models saved during
0012 %            one run of LearnBN, i.e. AllModels{i} = Cache{3,:} where Cache
0013 %            is the output of the EDA that learns BNs
0014 % OUTPUTS
0015 % run_structures{1} = indexmatrix(n,n): Associates an index to each possible edge in the network.
0016 % e.g. indexmatrix(1,2) = 1, number of edges m = n*(n+1)/2;
0017 % run_structures{2} = AllBigMatrices{nruns}(m,maxgen}: For each run contains whether the edge i appeared in generation j
0018 % run_structures{3} = AllSumMatrices(m,maxgen): = \sum_i^nruns AllBigMatrices{i},
0019 % i.e. the number of runs that each edge i appeared in generation j
0020 % run_structures{4} = AllContactMatrix{maxgen}(n,n): The number of runs in which edge i,j
0021 % was present in generation k.
0022 % run_structures{5} = SumAllContactMatrix(n,n): = \sum_k^maxgen AllContactMatrix{k}.
0023 % i.e. Total number of times edge i,j was present in all the structures
0024 % learned in all generations of all runs.
0025 %
0026 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0027 
0028  
0029 [m,indexmatrix] = Find_indexmatrix(n);
0030 
0031 
0032 % The matrices containing the occurrence of edges at each generation are constructed
0033 AllSumMatrices = zeros(m,maxgen);
0034  
0035  for j=1:maxgen  
0036   AllContactMatrix{j}= zeros(n,n);
0037  end
0038   
0039 for i=1:nruns,
0040  bnets = AllModels{i};
0041  BigMatrix = zeros(m,maxgen);
0042   for j=1:size(bnets,2)      
0043       bnet = bnets{j};
0044       sim_dag = (bnet.dag' + bnet.dag);
0045       AllContactMatrix{j} = AllContactMatrix{j} + sim_dag;
0046       edgeindex =   indexmatrix(find(sim_dag==1));
0047       if ~isempty(edgeindex)
0048         BigMatrix(edgeindex,j) = 1;       
0049       end
0050   end
0051   AllBigMatrices{i} = BigMatrix;
0052   AllSumMatrices = AllSumMatrices + BigMatrix;
0053 end
0054 
0055 SumAllContactMatrix = zeros(n,n);
0056 for j=1:maxgen  
0057   SumAllContactMatrix  =  SumAllContactMatrix  + AllContactMatrix{j};
0058 end
0059 
0060 run_structures{1} = indexmatrix;
0061 run_structures{2} = AllBigMatrices;
0062 run_structures{3} = AllSumMatrices;
0063 run_structures{4} = AllContactMatrix;
0064 run_structures{5} = SumAllContactMatrix;
0065 
0066 
0067 
0068

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