-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAdaBoost.h
More file actions
66 lines (45 loc) · 1.36 KB
/
AdaBoost.h
File metadata and controls
66 lines (45 loc) · 1.36 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
/**
* 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 ADABOOST_H
#define ADABOOST_H
#include "Data.h"
#include "Stump.h"
#include <vector>
using namespace std;
class AdaBoost
{
private:
vector<double> sampleWeight;
vector<Stump *> *stumps;
DataSet *dataset;
double calcSignificance(vector<int> errorIndex);
DataSet *generateNewDataSet(DataSet *dataset);
void normalizeWeight(double totalWeight);
double updateNewWeight(vector<int> errorIndex, double significance);
public:
const double EPSILON = 0.00001;
AdaBoost(DataSet *dataset);
AdaBoost(DataSet *dataset, int maxStumps);
AdaBoost(string fileName);
// Generate stumps for adaboost
void generateStumps(int maxStumps);
// Update weight for each sample
void updateSampleWeight(vector<int> errorIndex, double significance);
// Check if prediction is correct
bool predict(Data *data);
// Predict for attribute return the label
char predictNode(vector<int> attribute);
// Predict for a data return the label
char predict(Node *node, Data *data);
// Compute the accuracy of the model
double calcAccuracy(DataSet *dataset);
vector<char> guess(string filename);
//toString method
string toString();
};
#endif