summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2015-04-26 22:53:13 +0800
committerJoe Zhao <ztuowen@gmail.com>2015-04-26 22:53:13 +0800
commita8a7bf5f9b9a1eb0d41f839afd06cc532356a902 (patch)
treea70dbb38d76d30a84a8298096a40830ba7b528a7 /main.cpp
parentbe756a55086b5a8f62b979b456475c86ec2cfb61 (diff)
downloadranksvm-a8a7bf5f9b9a1eb0d41f839afd06cc532356a902.tar.gz
ranksvm-a8a7bf5f9b9a1eb0d41f839afd06cc532356a902.tar.bz2
ranksvm-a8a7bf5f9b9a1eb0d41f839afd06cc532356a902.zip
getAllData
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/main.cpp b/main.cpp
index d5c6f69..cf1dd14 100644
--- a/main.cpp
+++ b/main.cpp
@@ -24,7 +24,7 @@ int train(DataProvider &dp) {
DataList D;
LOG(INFO)<<"Training started";
- dp.getDataSet(D);
+ dp.getAllData(D);
LOG(INFO)<<"Read "<<D.getSize()<<" entries with "<< D.getfSize()<<" features";
rsvm->train(D);
std::vector<double> L;
@@ -49,30 +49,32 @@ int predict(DataProvider &dp) {
std::vector<double> L;
LOG(INFO)<<"Prediction started";
- dp.getDataSet(D);
- LOG(INFO)<<"Read "<<D.getSize()<<" entries with "<< D.getfSize()<<" features";
- rsvm->predict(D,L);
+ std::ofstream fout;
+ if (vm.count("output"))
+ fout.open(vm["output"].as<std::string>().c_str());
- if (vm.count("validate"))
+ while (!dp.EOFile())
{
- rank_accu(D,L);
+ dp.getDataSet(D);
+ LOG(INFO)<<"Read "<<D.getSize()<<" entries with "<< D.getfSize()<<" features";
+ rsvm->predict(D,L);
+
+ if (vm.count("validate"))
+ {
+ rank_accu(D,L);
+ }
+
+ if (vm.count("output"))
+ for (int i=0; i<L.size();++i)
+ fout<<L[i]<<std::endl;
+ else if (!vm.count("validate"))
+ for (int i=0; i<L.size();++i)
+ std::cout<<L[i]<<std::endl;
}
+ LOG(INFO)<<"Finished";
if (vm.count("output"))
- {
- LOG(INFO)<<"Finished,saving prediction";
- std::ofstream fout(vm["output"].as<std::string>().c_str());
-
- for (int i=0; i<L.size();++i)
- fout<<L[i]<<std::endl;
fout.close();
- }
- else if (!vm.count("validate"))
- {
- LOG(INFO)<<"Finished";
- for (int i=0; i<L.size();++i)
- std::cout<<L[i]<<std::endl;
- }
dp.close();
delete rsvm;
return 0;