-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDecTreeCwrite.m
More file actions
104 lines (80 loc) · 2.41 KB
/
DecTreeCwrite.m
File metadata and controls
104 lines (80 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function []=DecTreeCwrite(Bags,branches,storeBranchLength,storeBranchLogic,storeBranchVal,storeBranchVecI,Class,filename,uniqueclasses)
% x is the vector to be classified
% branches is the total number of branches in the tree
% storeBranchLength is the length of each branch
% x(storeBranchVecI) tells us which item of x is to evaluted at each branch
% storeBranchVal stores the vale which x(storeBranchVecI) is to be tested
% against
% storeBranchLogic tells us wheather the logic test result is 0 or 1,1 is x(storeBranchVecI) < storeBranchVal
% 0 is x(storeBranchVecI) >= storeBranchVal
ID=fopen(filename,'w');
fprintf(ID,'Number of Classes\n%i \n',length(uniqueclasses));
fprintf(ID,'Number of Bags\n%i \n',Bags);
fprintf(ID,'Number of Branches\n%i \n',branches);
fprintf(ID,'Max branch length\n%i \n',max(storeBranchLength));
fprintf(ID,'Branch Lengths\n');
for i=1:length(storeBranchLength)
fprintf(ID,'%i ',storeBranchLength(i));
end
fprintf(ID,'\n');
fprintf(ID,'Branch Logic\n');
for i=1:length(storeBranchLogic(:,1))
for j=1:length(storeBranchLogic(1,:))
fprintf(ID,'%i ',storeBranchLogic(i,j));
end
fprintf(ID,'\n');
end
fprintf(ID,'Branch Values\n');
for i=1:length(storeBranchVal(:,1))
for j=1:length(storeBranchVal(1,:))
fprintf(ID,'%1.20f ',storeBranchVal(i,j));
end
fprintf(ID,'\n');
end
fprintf(ID,'Branch Input Vector Index\n');
for i=1:length(storeBranchVecI(:,1))
for j=1:length(storeBranchVecI(1,:))
fprintf(ID,'%i ',storeBranchVecI(i,j));
end
fprintf(ID,'\n');
end
fprintf(ID,'Class Labels\n');
for i=1:length(Class)
if iscell(Class(i))==1
tmp=Class{i};
if isstr(tmp)==1;
fprintf(ID,'%s ',tmp);
elseif isnum(tmp)==1;
fprintf(ID,'%i ',tmp);
end
elseif isnum(Class(i))==1
tmp=Class(i);
fprintf(ID,'%i ',tmp);
end
end
fclose(ID);
% for bi=1:branches
% result(bi)=1;
%
% for ni=1: storeBranchLength(bi)
% test(bi,ni)=nan;
% if storeBranchLogic(bi,ni)==1
% if x(storeBranchVecI(bi,ni))<storeBranchVal(bi,ni)
% test(bi,ni)=1;
%
% end
% end
%
% if storeBranchLogic(bi,ni)==0
% if x(storeBranchVecI(bi,ni))>=storeBranchVal(bi,ni)
% test(bi,ni)=1;
% end
% end
%
% result(bi)=result(bi)*test(bi,ni);
%
% end
%
% end
%
% class=Class(find(result==1));