-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDataTable.cpp
More file actions
83 lines (62 loc) · 1.9 KB
/
DataTable.cpp
File metadata and controls
83 lines (62 loc) · 1.9 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "DataTable.hpp"
//Constructor
DataTable::DataTable(){
isPartitioned = 0;
testSize = 0;
}
//Destructor
DataTable::~DataTable(){}
//Copy constructor
DataTable::DataTable(const DataTable& dt)
: dataMatrix(dt.DataMatrix()),
columnNames(dt.ColumnNames()),
categoricalValues(dt.CategoricalValues()),
partition(dt.Partition()),
isPartitioned(dt.IsPartitioned()),
testSize(dt.TestSize()){}
//Getters
arma::mat DataTable::DataMatrix() const {
return dataMatrix;
}
std::vector<std::string> DataTable::ColumnNames() const {
return columnNames;
}
std::map<std::string, std::set<std::string>> DataTable::CategoricalValues() const {
return categoricalValues;
}
std::vector<bool> DataTable::Partition() const {
return partition;
}
bool DataTable::IsPartitioned() const {
return isPartitioned;
}
unsigned long DataTable::TestSize() const {
return testSize;
}
//Setters
void DataTable::SetDataMatrix(const arma::mat& matrix){
dataMatrix = matrix;
}
void DataTable::SetCategoricalValues(const std::map<std::string, std::set<std::string>> & catVal){
categoricalValues = catVal;
}
void DataTable::SetColumnNames(const std::vector<std::string>& colNames){
columnNames = colNames;
}
void DataTable::SetPartition(const std::vector<bool>& vector){
partition = vector;
}
void DataTable::SetIsPartitioned(const bool & isSet){
isPartitioned = isSet;
}
void DataTable::SetTestSize(const unsigned long & size){
testSize = size;
}
//Adding a key (that means column name) into a vector of column names
void DataTable::addKey(const std::string& keyName) {
columnNames.emplace_back(keyName);
}
//Adding a set of values for a categorical column with given index into categoricalValues
void DataTable::addCategoricalValues(unsigned columnIndex, std::set<std::string> setOfValues) {
categoricalValues[columnNames[columnIndex]] = setOfValues;
}