summaryrefslogtreecommitdiff
path: root/tools/dataProvider.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/dataProvider.h')
-rw-r--r--tools/dataProvider.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/tools/dataProvider.h b/tools/dataProvider.h
index eed3079..891be86 100644
--- a/tools/dataProvider.h
+++ b/tools/dataProvider.h
@@ -6,15 +6,12 @@
#include<vector>
#include<math.h>
-// TODO decide how to construct training data
-// One possible way for training data:
-// Matrix composed of an array of feature vectors
-// Labels are composed of linked list, such as
-// 6,3,4,0,5,0,0
-// => 0->6 | 1->3 | 2->4->5
-// How to compensate for non exhaustive labeling?
-// Use -1 to indicate not yet labeled data
-// -1s will be excluded from training
+// Training data(Rid):
+// First line: the total number of features(fsize)
+// from the second line to last-1
+// nametag(string) fsize number of features for nametag
+// possible: "-1" nametag mean don't care(partially implemented, not sure)
+// last line(delimiter to terminate data read): 0
typedef struct DataEntry{
std::string qid;
@@ -70,7 +67,6 @@ public:
all.clear();
}
void setfSize(int fsize){n=fsize;}
- inline int getfSize(){return n;}
void addEntry(DataEntry* d){
int ext=false;
all.push_back(d);
@@ -92,6 +88,8 @@ public:
d->rank=uniq.size()-1;
}
}
+ // A lot of getters
+ inline int getfSize(){return n;}
inline DataEntry* getU(int x)
{
return uniq[x];
@@ -182,9 +180,11 @@ public:
}
return res;
}
+ // master cal -> possible multiplexing
inline double cal(Eigen::VectorXd *id,Eigen::VectorXd *oth,int i) {
return fabs((*id)[i] - (*oth)[i]);
}
+ // TODO getvec as VectorXd -> deprecating due to performance issues
inline Eigen::VectorXd getVec(int x){
int a,b,q=getqSize();
a=x/q;
@@ -207,6 +207,7 @@ public:
res(i)=cal(id,oth,i);
return res;
};
+ // w*Vec -> linear factor
inline double getVecDot(int x,const Eigen::VectorXd &w)
{
int a,b,q=getqSize();
@@ -230,6 +231,7 @@ public:
res += cal(id,oth,i)*w[i];
return res;
}
+ // w*Vec -> linear factor
inline void addVecw(int x,double w,Eigen::VectorXd &X)
{
int a,b,q=getqSize();
@@ -251,6 +253,7 @@ public:
for (int i=0;i<n;++i)
X[i] += cal(id,oth,i)*w;
}
+ // get label of vector x
inline double getL(int x){
int a,b,q=getqSize();
a=x/q;