-
Notifications
You must be signed in to change notification settings - Fork 1
/
TrainStats.hpp
executable file
·75 lines (53 loc) · 1.73 KB
/
TrainStats.hpp
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
#include <iostream>
#include <fstream>
using namespace std;
class TrainStats {
public:
static TrainStats &get() {
static TrainStats instance;
return instance;
}
void addSplit(int treeNo, int nodeID, int measureMode);
void addMeasure(int treeNo, int channel, int measureMode, float distance);
void addInvalidTest(int treeNo, int nodeID);
private:
TrainStats();
~TrainStats();
TrainStats(TrainStats const &);
void operator=(TrainStats const &);
/*member*/
vector<string> data;
vector<ofstream *> splitOutFiles;
vector<ofstream *> measureOutFiles;
vector<ofstream *> invOutFiles;
};
TrainStats::TrainStats() {
for (int i = 0; i < 15; ++i) {
stringstream splitSs, measureSs, invSs;
splitSs << "train_stats_raw/trainstats_split_" << i << ".txt";
measureSs << "train_stats_raw/trainstats_measure_" << i << ".txt";
invSs << "train_stats_raw/invalid_tests_" << i << ".txt";
splitOutFiles.push_back(new ofstream(splitSs.str().c_str()));
measureOutFiles.push_back(new ofstream(measureSs.str().c_str()));
invOutFiles.push_back(new ofstream(invSs.str().c_str()));
}
}
TrainStats::~TrainStats() {
for (int i = 0; i < splitOutFiles.size(); ++i) {
splitOutFiles[i]->close();
delete splitOutFiles[i];
measureOutFiles[i]->close();
delete measureOutFiles[i];
}
splitOutFiles.clear();
measureOutFiles.clear();
}
void TrainStats::addSplit(int treeNo, int nodeID, int measureMode) {
*splitOutFiles[treeNo] << nodeID << " " << measureMode << "\n";
}
void TrainStats::addMeasure(int treeNo, int channel, int measureMode, float distance) {
*measureOutFiles[treeNo] << channel << " " << measureMode << " " << distance << "\n";
}
void TrainStats::addInvalidTest(int treeNo, int nodeID) {
*invOutFiles[treeNo] << nodeID << "\n";
}