Home > Mateda2.0 > learning > LearnGaussianNetwork.m

LearnGaussianNetwork

PURPOSE ^

[bnet] = LearnGaussianNetwork(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)

SYNOPSIS ^

function[bnet] = LearnGaussianNetwork(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)

DESCRIPTION ^

 [bnet] = LearnGaussianNetwork(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)
 LearnGaussianNetwork:     Learns the Gaussian network from the given population using
             Gaussian network learning algorithms of the BNtools and
             libraries (see references in the documentation)
 INPUTS
 k: Current generation
 NumbVar: Number of variables
 AuxPop: Selected population (data set for learning the BN
 AuxFunVal: Evaluation of the data set (required for some learning algorithms, not for this one)
 Card: Vector with the dimension of all the variables. 
 learning_params{1} = TypeLearning: Type of method used for learning the Bayesian network
                         TypeLearning = {'tree','k2','k2t'}.  
                         'tree':  MWST based tree algorithm. 'k2': K2  algorithm initialized from a random 
                         ordering of the variables k2t:  K2  algorithm initialized from a tree dag ordering
 learning_params{2} = MaxParent: Maximum number of parents for the Bayesian Networks or
                         maximum size of the conditioning set for PC. By default, MaxParent = n.
 learning_params{3} = verbose = {'yes','no'}. Whether to display the output of K2 learning algorithm while running 
 OUTPUTS
 bnet: Gaussian network learned from the selected population 

 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[bnet] =  LearnGaussianNetwork(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)
0002 % [bnet] = LearnGaussianNetwork(k,NumbVar,Card,AuxPop,AuxFunVal,learning_params)
0003 % LearnGaussianNetwork:     Learns the Gaussian network from the given population using
0004 %             Gaussian network learning algorithms of the BNtools and
0005 %             libraries (see references in the documentation)
0006 % INPUTS
0007 % k: Current generation
0008 % NumbVar: Number of variables
0009 % AuxPop: Selected population (data set for learning the BN
0010 % AuxFunVal: Evaluation of the data set (required for some learning algorithms, not for this one)
0011 % Card: Vector with the dimension of all the variables.
0012 % learning_params{1} = TypeLearning: Type of method used for learning the Bayesian network
0013 %                         TypeLearning = {'tree','k2','k2t'}.
0014 %                         'tree':  MWST based tree algorithm. 'k2': K2  algorithm initialized from a random
0015 %                         ordering of the variables k2t:  K2  algorithm initialized from a tree dag ordering
0016 % learning_params{2} = MaxParent: Maximum number of parents for the Bayesian Networks or
0017 %                         maximum size of the conditioning set for PC. By default, MaxParent = n.
0018 % learning_params{3} = verbose = {'yes','no'}. Whether to display the output of K2 learning algorithm while running
0019 % OUTPUTS
0020 % bnet: Gaussian network learned from the selected population
0021 %
0022 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0023 
0024 TypeLearning = char(cellstr(learning_params{1}(1)));
0025 MaxParent = cell2num(learning_params{1}(2));
0026 %verbose = char(cellstr(learning_params{1}(3)));
0027 
0028 
0029 scoring_fn = 'bic';
0030 
0031 SelPop = AuxPop'+1;  % For the bnet learning procedure, variables are rows and observations columns
0032                      % Entries in the matrix should be non-zero
0033 
0034 % All nodes are set to be gaussian
0035 for i=1:NumbVar 
0036  nodetype{i} = 'gaussian';
0037 end
0038 
0039  
0040 switch lower(TypeLearning)
0041    case {'tree'}
0042     % MWST based tree algorithm
0043     root = fix(rand*NumbVar)+1;
0044     dag = full(learn_struct_mwst(SelPop,[],ones(NumbVar,1),nodetype,'bic',root));
0045    case {'k2'} 
0046    %K2 algorithm
0047     root = fix(rand*NumbVar)+1;
0048     order = randperm(NumbVar);
0049     dag =  learn_struct_K2(SelPop,ones(1,NumbVar),order,'type',nodetype,'max_fan_in',MaxParent,'discrete',[],'scoring_fn',scoring_fn,'params',[]);   
0050    case {'k2t'} 
0051    %K2 algorithm initialized from a tree dag
0052     root = fix(rand*NumbVar)+1;
0053     dag = full(learn_struct_mwst(SelPop,[],ones(NumbVar,1),nodetype,'bic',root));
0054     order = topological_sort(dag);
0055     dag =  learn_struct_K2(SelPop,ones(NumbVar,1),order,'type',nodetype,'max_fan_in',MaxParent,'discrete',[],'scoring_fn',scoring_fn,'params',[]);   
0056    end,
0057 
0058 %dag
0059 bnet = mk_bnet(dag,ones(NumbVar,1),'discrete',[]);
0060 % All nodes are set to be gaussian
0061 for i=1:NumbVar 
0062  bnet.CPD{i} = gaussian_CPD(bnet,i);
0063 end,
0064 bnet = learn_params(bnet,SelPop);
0065 %figure
0066 %draw_graph(dag);
0067

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