diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-03-07 16:42:46 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-03-07 16:42:46 +0800 |
commit | f50bb1ee0d6011969fcfc7cb084bab0ce9c4dd39 (patch) | |
tree | ff6a5d0de7f357772fb902fb357d8bfa9fe58082 /model/ranksvm.cpp | |
parent | bddad20b835a83923901106961adc14c5eb6e3db (diff) | |
download | ranksvm-f50bb1ee0d6011969fcfc7cb084bab0ce9c4dd39.tar.gz ranksvm-f50bb1ee0d6011969fcfc7cb084bab0ce9c4dd39.tar.bz2 ranksvm-f50bb1ee0d6011969fcfc7cb084bab0ce9c4dd39.zip |
scaffolding, decided to abandon libsvm format & using matrices for easier input & output operation
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 |