summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2015-03-16 14:12:03 +0800
committerJoe Zhao <ztuowen@gmail.com>2015-03-16 14:12:03 +0800
commit0c92357c8ab3a616e51b7cf83d3c038027b8fa99 (patch)
tree11c959e282bc3ad67af16a5d51ea2846e5ab7c0b
parenta698a1e2cceb6947e244a0de01424894dc37028a (diff)
downloadranksvm-0c92357c8ab3a616e51b7cf83d3c038027b8fa99.tar.gz
ranksvm-0c92357c8ab3a616e51b7cf83d3c038027b8fa99.tar.bz2
ranksvm-0c92357c8ab3a616e51b7cf83d3c038027b8fa99.zip
svm model struct
-rw-r--r--model/ranksvmtn.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/model/ranksvmtn.cpp b/model/ranksvmtn.cpp
index 6a7057d..539ab5e 100644
--- a/model/ranksvmtn.cpp
+++ b/model/ranksvmtn.cpp
@@ -6,6 +6,26 @@ using namespace Eigen;
const int maxiter = 10;
const double prec=1e-3;
+int cg_solve(const MatrixXd &A, const VectorXd &b, const VectorXd &x)
+{
+ double alpha,beta,r_1,r_2;
+ VectorXd p = x;
+ VectorXd q;
+ VectorXd res;
+ while (1)
+ {
+ beta = r_1/r_2;
+ p = res + beta*p;
+ q = A*p;
+ alpha = r_1/p.dot(q);
+ // Non preconditioned version
+ alpha = p.dot(p)/(p.dot(q));
+ res=res-alpha*q;
+ break;
+ }
+ return 0;
+}
+
// Calculate objfunc gradient & support vectors
int objfunc_linear(const VectorXd &w,const double C,const VectorXd &pred,const VectorXd &grad, double &obj,MatrixXd &sv)
{
@@ -17,12 +37,13 @@ int objfunc_linear(const VectorXd &w,const double C,const VectorXd &pred,const V
sv(i,i)=1;
else
sv(i,i)=0;
+ return 0;
}
// line search
int line_search(const VectorXd &w,const double C,const VectorXd &step,VectorXd &pred,double &t)
{
-
+ return 0;
}
int RSVMTN::train(DataSet &D, Labels &label){