-
Notifications
You must be signed in to change notification settings - Fork 0
/
TreeNode.h~
63 lines (50 loc) · 1.01 KB
/
TreeNode.h~
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
#include "Record.h"
#define NUM_TARGET_CATEGORIES 29
#define MIN_TARGET_CATEGORY 1
#define MAX_TARGET_CATEGORY (NUM_TARGET_CATEGORIES + MIN_TARGET_CATEGORY -1 )
#define TARGET_CATEGORY_ARRAYINDEX(i) (i- MIN_TARGET_CATEGORY)
#define FLOAT_INFINITY 900000000000000.0
typedef struct TreeNode
{
AttrIndex dividingAttribute;
struct TreeNode *parent;
float divisionPoint;
Record *data;
} TreeNode;
#define TOTAL_3
//float Entropy(Record *data);
float ResultingEntropy(TreeNode *t);
float AttributeDivisionPoint(TreeNode *t)
{
int n;
float xbar;
float ybar;
float xy;
float xsq;
Record *r;
n=0;
xbar=ybar=xy=xsq=.0;
for (r= t->data->next; r; r= r->next)
{
n++;
}
}
AttrIndex ChooseDividingAttribute(TreeNode *t)
{
int i;
int bestI= -3;
float bestE= FLOAT_INFINITY;
float entropy;
for (i=Sex; i<= ShellWeight; i++)
{
t->dividingAttribute= i;
t->divisionPoint= AttributeDivisionPoint(t);
entropy= ResultingEntropy(t);
if (entropy < bestE)
{
bestE=entropy;
bestI= i;
}
}
return i;
}