Home > Mateda2.0 > ScriptsMateda > FitnessModScripts > BN_kMPCs.m

BN_kMPCs

PURPOSE ^

%%%%%%%%%%%%%%% MODEL EVALUATION EXAMPLES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

%%%%%%%%%%%%%%% MODEL EVALUATION EXAMPLES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%% Example 1: Determination of the k most probable
%%%%%%%%%%%%%%%            configurations of a model of a random population
% First, a dataset is generated, a Bayesian network is learned from the
% set, and the k most probable configurations of the network are found.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%% MODEL EVALUATION EXAMPLES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %
0003 %%%%%%%%%%%%%%%% Example 1: Determination of the k most probable
0004 %%%%%%%%%%%%%%%%            configurations of a model of a random population
0005 %% First, a dataset is generated, a Bayesian network is learned from the
0006 %% set, and the k most probable configurations of the network are found.
0007 
0008 % Characteristics of the data set are defined
0009 NumbVar = 10;
0010 Card = 2*ones(1,NumbVar);
0011 N = 20;
0012 Pop = fix(2*rand(N,NumbVar))'+1;
0013 
0014 
0015 %%%%%  Characteristics of the Bayesian network and learning algorithm set are defined
0016 
0017 MaxParent = 5;
0018 scoring_fn = 'bic';
0019 for i=1:NumbVar 
0020  nodetype{1,i} = 'tabular';
0021 end
0022 
0023 % Structure of the Bayesian network are learned
0024 root = 1;
0025 order = randperm(NumbVar);
0026 dag =  learn_struct_K2(Pop,Card,order,'max_fan_in',MaxParent,'scoring_fn',scoring_fn);   
0027 
0028 init_bnet = mk_bnet(dag,Card);  
0029 % All nodes are set to be discrete
0030 for i=1:NumbVar 
0031  init_bnet.CPD{i} = tabular_CPD(init_bnet,i);
0032 end,
0033 
0034 % Parameters Bayesian network are learned
0035 bnet = learn_params(init_bnet,Pop);
0036 
0037 % Bayesian network is painted
0038 figure
0039 draw_graph(dag);
0040 
0041 
0042 k = 10;
0043 % k most probable configurations are found
0044 [k_solutions,k_probvalues] =  Find_kMPEs(bnet,k,Card)

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