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

# BN_Prediction

## PURPOSE

EXAMPLE 2: Evaluation of the prediction capability of the models

## SYNOPSIS

This is a script file.

## DESCRIPTION

     EXAMPLE 2: Evaluation of the prediction capability of the models
                learned during the evolution of an EDA for a multiobjective function
                The prediction is measured using the correlation between the probability
                given by the models to the solutions and its fitness values

## CROSS-REFERENCE INFORMATION

This function calls:

- RunEDA [AllStat,Cache]=RunEDA(PopSize,n,F,Card,cache,edaparams)
- CreateListFactorsCircularNK [ListFactors] = CreateListFactorsCircularNK(NumberVar,k)
- ReadFunctionsFromData [Tables] = ReadFunctionsFromData(filename,ListFactors,Card)
- BN_Fitness_Corr [bn_fit_corr] = BN_Fitness_Corr(bnet,Pop,FunVal):
- FindListCard [ListFactorsCard] = FindListCard(ListFactors,Card)
- apcluster This program has been downloaded from
- FindParetoSet [Index]=FindParetoSet(Pop,FunVal)

This function is called by:

## SOURCE CODE

    0001  % EXAMPLE 2: Evaluation of the prediction capability of the models
    0002  %            learned during the evolution of an EDA for a multiobjective function
    0003  %            The prediction is measured using the correlation between the probability
    0004  %            given by the models to the solutions and its fitness values
    0005
    0006  %%%%% First, the EDA is defined
    0007  clear edaparams;
    0008  PopSize = 1000; n = 50; cache = [1,1,1,1,1]; Card = 2*ones(1,n); MaxGen = 30;
    0009  global FunctionTables;
    0010  global FunctionStructure;
    0011  global FunctionAccCard;
    0012  global SelectedObjectives;
    0013
    0014  [FunctionStructure] =  CreateListFactorsCircularNK(n,4); % The circular structure is created
    0015  [FunctionTables] = ReadFunctionsFromData('testNK_fnt_N50_k4Inst_1.txt',FunctionStructure,Card); % Values are read from a file
    0016  [FunctionAccCard] = FindListCard(FunctionStructure,Card); % Auxiliary structure for function evaluation
    0017  SelectedObjectives = [1:4:48];
    0018
    0019  F = 'PartialEvaluateGeneralFunction';  % General function that uses global variables FunctionTables, FunctionStructure and FunctionAccCard.
    0020  selparams(1:2) = {0.5,'ParetoRank_ordering'};
    0021  edaparams{1} = {'selection_method','truncation_selection',selparams};
    0022  edaparams{2} = {'replacement_method','best_elitism',{'ParetoRank_ordering'}};
    0023  edaparams{3} = {'stop_cond_method','max_gen',{MaxGen}};
    0024
    0025  %%%%% Second, the EDA is executed and all the information is saved in Cache
    0026
    0027  [AllStat,Cache]=RunEDA(PopSize,n,F,Card,cache,edaparams);
    0028
    0029
    0030  %%%%% Third the information is extracted and analyzed
    0031
    0032  AllSols = []; AllVals = [];
    0033  for i=1:MaxGen,
    0034   AllSols = [AllSols;Cache{1,i}];   % All the populations
    0035   AllVals = [AllVals;Cache{4,i}];   % All the evaluations
    0036  end
    0037
    0038  Index = FindParetoSet(AllSols,AllVals); % The set of Pareto solutions found by the EDA is extracted
    0039  ParetoPop = AllSols(Index,:);
    0040  ParetoVals = AllVals(Index,:);
    0041
    0042  parallelcoords(ParetoVals); % The Pareto set is shown using parallel coordinates
    0043  ObjectivesCorr = corr(ParetoVals); % The correlations between the objectives are computed.
    0044  [idx,netsim,dpsim,expref]=apcluster(ObjectivesCorr,mean(ObjectivesCorr)); % Affinity propagation is used
    0045                                                                            % to reduce the number of objectives
    0046                                                                            % by selecting correlated variables
    0047
    0048  for i=1:MaxGen,              % The correlations between the probabilities of each BN and each of
    0049   bnet = Cache{3,i};          % the problem objectives are computed using the Pareto Set
    0050   All_BN_Fit_Corr(i,:) =  BN_Fitness_Corr(bnet,ParetoPop,ParetoVals)
    0051  end
    0052