To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / _FullBNT / BNT / CPDs / @tree_CPD / tree_CPD.m @ 8:b5b38998ef3b
History | View | Annotate | Download (882 Bytes)
| 1 |
function CPD = tree_CPD(varargin) |
|---|---|
| 2 |
%DTREE_CPD Make a conditional prob. distrib. which is a decision/regression tree. |
| 3 |
% |
| 4 |
% CPD =dtree_CPD() will create an empty tree. |
| 5 |
|
| 6 |
if nargin==0 |
| 7 |
% This occurs if we are trying to load an object from a file. |
| 8 |
CPD = init_fields; |
| 9 |
clamp = 0; |
| 10 |
CPD = class(CPD, 'tree_CPD', discrete_CPD(clamp, [])); |
| 11 |
return; |
| 12 |
elseif isa(varargin{1}, 'tree_CPD')
|
| 13 |
% This might occur if we are copying an object. |
| 14 |
CPD = varargin{1};
|
| 15 |
return; |
| 16 |
end |
| 17 |
|
| 18 |
CPD = init_fields; |
| 19 |
|
| 20 |
|
| 21 |
clamped = 0; |
| 22 |
fam_sz = []; |
| 23 |
CPD = class(CPD, 'tree_CPD', discrete_CPD(clamped, fam_sz)); |
| 24 |
|
| 25 |
|
| 26 |
%%%%%%%%%%% |
| 27 |
|
| 28 |
function CPD = init_fields() |
| 29 |
% This ensures we define the fields in the same order |
| 30 |
% no matter whether we load an object from a file, |
| 31 |
% or create it from scratch. (Matlab requires this.) |
| 32 |
|
| 33 |
%init the decision tree set the root to null |
| 34 |
CPD.tree.num_node = 0; |
| 35 |
CPD.tree.root=1; |
| 36 |
CPD.tree.nodes=[]; |
| 37 |
|