forked from 20020001-UET/dsa-decision-tree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTree.h
61 lines (42 loc) · 1.19 KB
/
Tree.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
/*
* 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 TREE_H
#define TREE_H
#include "Node.h"
#include "Data.h"
#include "Console.h"
class Tree
{
private:
Node *root;
Console *console;
public:
Tree(bool consoleActivate = true);
Tree(vector<Data *> *dataset, int minSize, int maxDepth, bool consoleActivate = true);
~Tree();
/**
* @brief Building a tree function.
*
* @param dataset The main dataset.
* @param minSize Minimum Node Records.
* @param maxDepth Maximum Tree Depth.
*/
void buildTree(vector<Data *> *dataset, int minSize, int maxDepth);
double calcAccuracy(DataSet *dataset);
bool predict(Data *data);
bool predict(Node *node, Data *data);
char predictNode(Data *data);
char predictNode(Node *node, Data *data);
void printTree();
void import(string importData);
string getExport();
void exportNode(string& exportData, Node* node, int& count, int parentCode, int direction);
};
Tree *buildBestModel(DataSet *train, DataSet *valid);
void printNode(Node *node, int depth);
#endif