-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNode.h
51 lines (40 loc) · 1.18 KB
/
Node.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
/*
* This file is part of dsa-decision-tree
*
* Developed for the DSA UET course.
* This project was developed by Ba Luong and Gia Linh.
*/
#pragma once
#ifndef NODE_H
#define NODE_H
#include "Data.h"
#include "CostCalc.h"
#include "BitMask.h"
#include "SplitData.h"
#include <math.h>
using namespace std;
class Node
{
public:
Node *left;
Node *right;
int code;
virtual bool isTerminal() = 0;
virtual bool compare(Data *data) = 0;
virtual char getLabel() = 0;
virtual string toString() = 0;
virtual void setCode(int _code) = 0;
virtual string getExport() = 0;
Node(int _code = 0) : code(_code) { left = right = NULL; }
virtual ~Node()
{
delete left;
delete right;
}
};
SplitData::GroupSplitData getSplit(vector<Data *> *dataset, SplitData::SPLIT_VAL method = SplitData::COMPARISON);
SplitData::GroupSplitData getRandomSplit(vector<Data *> *dataset, SplitData::SPLIT_VAL method = SplitData::COMPARISON);
char toTerminal(DataSet *data);
// Create child splits for a node or make terminal
void split(Node *&node, DataSet *dataset, int minSize, int maxDepth, int depth);
#endif