I am using K2 algorithm of Bayesian Network praposed by Cooper and Harkovitz (1992).
I found the codes developed by Guangdi Li for learning DAG structure.
The code is running perfect (thanks to Li). I have to make little adjustments according to my requirment.
So, here is the issue.
The code suggested by Li is below.
load ( 'C: \ Users \ ashwa \ Desktop \ aitec \ Work \ DIAMOND \ Task-2 \ MATLAB for Bayes \ K2 \ Sample_1.mat' );
LGObj = ConstructLGObj (Sample_1);
Order = 1: 143;
u = 20;
[DAG, K2Score] = k2 (LGObj, Order, u);
h = view (biograph (DAG));
I have to make adjustmet for the "Order". I need that order must be generated randomly and perform 5000 iteration and then search the maximum liklyhood network from those 5000 iterations
So, to randomize the order, i have written
Order = reshape (randperm (LGObj.VarNumber), 1, length (randperm (LGObj.VarNumber)));
. It is working fine. No issues here. If I repalce the order in Li's code with this one, I will get a graph with randomly generated order.
Now I want to repeat this process altleast 5000 times and I need my output as a DAG matrix which have maximum sum (K2Score).
Thank you very much in advance.