diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-06-08 11:20:36 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-06-08 11:20:36 +0800 |
commit | 93b28277476de5d4fbfbf5ac236f9f619d482c46 (patch) | |
tree | faee604441376745aa3b1fad4e024365384403e8 /tools | |
parent | 3c62d2ca6c0c9cd7c8e72c9abf9d58e311b9b2e1 (diff) | |
download | ranksvm-93b28277476de5d4fbfbf5ac236f9f619d482c46.tar.gz ranksvm-93b28277476de5d4fbfbf5ac236f9f619d482c46.tar.bz2 ranksvm-93b28277476de5d4fbfbf5ac236f9f619d482c46.zip |
separation, HE
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dataProvider.h | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/tools/dataProvider.h b/tools/dataProvider.h index 65a6b63..eed3079 100644 --- a/tools/dataProvider.h +++ b/tools/dataProvider.h @@ -147,8 +147,43 @@ public: oth = &(all[b+1]->feature); } for (int i=0;i<n;++i) - res += sqrt((*id)[i] * (*oth)[i]); - return -log(res); + { + double acc=0; + for (int j=0;j<16;++j,++i) + acc += sqrt((*id)[i] * (*oth)[i]); + res-=log(acc+1e-30); + } + return res; + } + inline double getHell(int x){ + int a,b,q=getqSize(); + a=x/q; + b=x%q; + double res = 0; + Eigen::VectorXd *id,*oth; + if (single) + { + id = &(uniq[a]->feature); + oth = &(other[b]->feature); + } + else { + id = &(all[a]->feature); + if (b<a) + oth = &(all[b]->feature); + else + oth = &(all[b+1]->feature); + } + for (int i=0;i<n;++i) + { + double acc=0; + for (int j=0;j<16;++j,++i) + acc += sqrt((*id)[i] * (*oth)[i]); + res+=sqrt(1-acc); + } + return res; + } + inline double cal(Eigen::VectorXd *id,Eigen::VectorXd *oth,int i) { + return fabs((*id)[i] - (*oth)[i]); } inline Eigen::VectorXd getVec(int x){ int a,b,q=getqSize(); @@ -167,7 +202,10 @@ public: else oth = &(all[b+1]->feature); } - return (*id-*oth).cwiseAbs(); + Eigen::VectorXd res(n); + for (int i=0;i<n;++i) + res(i)=cal(id,oth,i); + return res; }; inline double getVecDot(int x,const Eigen::VectorXd &w) { @@ -189,7 +227,7 @@ public: oth = &(all[b+1]->feature); } for (int i=0;i<n;++i) - res += fabs((*id)[i] - (*oth)[i])*w[i]; + res += cal(id,oth,i)*w[i]; return res; } inline void addVecw(int x,double w,Eigen::VectorXd &X) @@ -211,7 +249,7 @@ public: oth = &(all[b+1]->feature); } for (int i=0;i<n;++i) - X[i] += fabs((*id)[i] - (*oth)[i])*w; + X[i] += cal(id,oth,i)*w; } inline double getL(int x){ int a,b,q=getqSize(); |