diff options
Diffstat (limited to 'model/ranksvm.cpp')
-rw-r--r-- | model/ranksvm.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/model/ranksvm.cpp b/model/ranksvm.cpp index 38fb70c..b15d2ef 100644 --- a/model/ranksvm.cpp +++ b/model/ranksvm.cpp @@ -1 +1,43 @@ -#include"ranksvm.h"
\ No newline at end of file +#include"ranksvm.h" +#include"ranksvmtron.h" +#include<iostream> +#include<fstream> +#include<string> + +using namespace Eigen; + +int RSVM::saveModel(string fname){ + + std::ofstream fout(fname); + fout<<this->getName()<<endl; + fout<<this->model; + return 0; +} + +static RSVM* RSVM::loadModel(string fname){ + std::ifstream fin(fname); + std::string type; + int fsize; + fin>>type; + fin>>fsize; + + RSVM* rsvm; + + // TODO multiplex type + if (type=="TN") + RSVM = new RSVMTN(); + + rsvm->fsize=fsize; + VectorXd model; + fin>>model; + rsvm->setModel(model); + + return rsvm; +} + +int RSVM::setModel(Eigen::VectorXd model) { + if (model.cols()!=fsize) + LOG(FATAL) << "Feature size mismatch";; + this->model=model; + return 0; +}
\ No newline at end of file |