-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataset.hpp
62 lines (49 loc) · 1.29 KB
/
Dataset.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
#ifndef Dataset_hpp
#define Dataset_hpp
#include "Feature.hpp"
#include "Instance.hpp"
struct DatasetMetadata {
public:
string name;
int numOfFeatures;
vector<Feature*> featureList;
int numOfClasses;
Feature* classVariable;
DatasetMetadata() : name(""), numOfFeatures(-1), featureList(0), numOfClasses(-1), classVariable(0) {}
~DatasetMetadata() {
for (Feature* f : featureList)
if (f) delete f;
if (classVariable)
delete classVariable;
}
};
class Dataset {
private:
DatasetMetadata* metadata;
vector<Instance*> trainSet;
vector<Instance*> testSet;
Dataset() {
metadata = new DatasetMetadata;
}
public:
static Dataset* loadDataset(string trainFile, string testFile);
const DatasetMetadata* getMetadata() const {
return metadata;
}
const vector<Instance*>& getTrainSet() const {
return trainSet;
}
const vector<Instance*>& getTestSet() const {
return testSet;
}
~Dataset() {
if (metadata)
delete metadata;
for (Instance* i : trainSet)
if (i) delete i;
for (Instance* i : testSet)
if (i) delete i;
}
string toString() const;
};
#endif /* Dataset_hpp */