-
Notifications
You must be signed in to change notification settings - Fork 0
/
bnb.h
109 lines (85 loc) · 2.21 KB
/
bnb.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
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
105
106
107
108
// SWAMI KARUPPASWAMI THUNNAI
#pragma once
#define NODEBUG 0
#define DEBUG 1
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
class __individual_column_label_count
{
private:
unsigned long int column_value;
unsigned long int label_value;
unsigned long int count;
public:
__individual_column_label_count(unsigned long int column_value, unsigned long int label_value, unsigned long int count) : column_value(column_value), label_value(label_value), count(count) {}
unsigned long int get_column_value()
{
return column_value;
}
unsigned long int get_label_value()
{
return label_value;
}
unsigned long int get_count()
{
return count;
}
void increment_count()
{
count++;
}
};
class __Xi_probability
{
private:
unsigned long int X_val;
unsigned long int y_val;
double p;
public:
__Xi_probability(unsigned long int X_val, unsigned long int y_val, double p): X_val(X_val), y_val(y_val), p(p) {}
unsigned long int get_X()
{
return X_val;
}
unsigned long int get_y()
{
return y_val;
}
double get_p()
{
return p;
}
};
class bnb
{
private:
// Independent variable
std::vector<std::vector<unsigned long int>> X;
// Dependent variable
std::vector<unsigned long int> y;
// print verbose message
unsigned short int verbose;
// Unique labels of y
std::set<unsigned long int> unique_labels;
// Probabilties of y
std::map<unsigned long int, double> y_prob;
// Individual probability
std::map<unsigned long int, std::vector<__Xi_probability>> individual_probability;
// X probability for labels/classes
std::map<unsigned long int, double> X_prob;
private:
void print(std::string message);
void get_unique_labels();
void get_probabilities_of_y();
void get_indiviudual_probabilities();
void get_column_probability(unsigned long int column_index);
void update_icl_count(unsigned long int X_val, unsigned long int y_val, std::vector<__individual_column_label_count>& icl);
/*void calculate_X_prob();*/
public:
bnb(std::vector<std::vector<unsigned long int>> X, std::vector<unsigned long int> y, unsigned short int verbose) : X(X), y(y), verbose(verbose) {}
void fit();
std::map<unsigned long int, double> predict(std::vector<unsigned long int> test);
};