image thumbnail
from K2 algorithm for learning DAG structure in Bayesian network by Guangdi Li
This is the code of Cooper's K2 algorithm proposed in 1992, quick and convenient for using.

ControlCentor.m
%ControlCentor
% when you test the code,please correct the directory in next command
load('G:\K2\Sample.mat');

% Sample is a variable that saves our training database.
LGObj = ConstructLGObj( Sample); % construct an object

Order = [3 4 1 2 5 8 7 10 9 6]; % Order is the ordering of the input in K2 algorithm

u = 4; % u is the maximum edges of node in output graph.

[ DAG,K2Score ] = k2( LGObj,Order,u )
h = view(biograph( DAG ))

Contact us at files@mathworks.com