-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDataObject.cpp
More file actions
99 lines (78 loc) · 1.79 KB
/
DataObject.cpp
File metadata and controls
99 lines (78 loc) · 1.79 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
///////////////////////////////////////////////////////////
// DataObject.cpp
// Implementation of the Class DataObject
// Created on: 07-Lie-2013 20:07:29
// Original author: Povilas
///////////////////////////////////////////////////////////
/*! \class DataObject
\brief A class of methods and attributes for manipulating features in data vectors.
*/
#include "DataObject.h"
DataObject::DataObject()
{
classLabel = -1;
}
DataObject::~DataObject()
{
}
DataObject::DataObject(int feature_count)
{
classLabel = -1;
featureCount = feature_count;
}
DataObject::DataObject(std::vector<double> vector, int cLabel)
{
features = vector;
featureCount = features.size();
this->classLabel = cLabel;
}
DataObject::DataObject(int feature_count, int class_label)
{
featureCount = feature_count;
classLabel = class_label;
}
int DataObject::getClassLabel()
{
return this->classLabel;
}
int DataObject::getFeatureCount()
{
//return features.size();
return featureCount;
}
void DataObject::setClassLabel(int class_Label)
{
this->classLabel = class_Label;
}
bool DataObject::IsIdentical(DataObject obj)
{
bool ats = false;
int k = 0;
int n = obj.getFeatureCount();
for (int i = 0; i < n; i++)
if (this->features.at(i) == obj.features.at(i))
k++;
if (k == n)
ats = true;
return ats;
}
void DataObject::setNumOfFeatures(int n)
{
features.reserve(n);
}
double DataObject::getFeatureAt(int index)
{
return features.at(index);
}
void DataObject::updateFeature(int featureIndex, double newValue)
{
features.at(featureIndex) = newValue;
}
/*void DataObject::updateClass(int objectIndex, double newValue)
{
classLabel = newValue;
}*/
std::vector<double> DataObject::getFeatures()
{
return features;
}