-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvmtask.cpp
48 lines (46 loc) · 1.49 KB
/
svmtask.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//============================================================================
// Name : 0.cpp
// Author : Patrick Nichols
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include "SVMOptions.h"
#include "SMOSolver.h"
#include "SMOSolverPth.h"
#include "SVMPredictor.h"
#include "svm_stopwatch.h"
using namespace std;
int main ( int argc, char **argv )
{
typedef double SVMREAL;
svmpack::svm_stopwatch timer;
timer.start();
svmpack::SVMOptions<SVMREAL> options ( argc, argv );
timer.stop();
cerr << "Time to get options " << timer.elapsedTime() << "s \n";
cerr << options << endl;
if ( options.getTask() == 0 ) {
timer.clear();
timer.start();
if ( options.getNThreads() ) {
svmpack::SMOSolverPth<SVMREAL> solver ( options );
solver.train();
solver.outputModelFile();
} else {
svmpack::SMOSolver<SVMREAL> solver ( options );
solver.train();
solver.outputModelFile();
}
timer.stop();
cerr << "time to train and write model = " << timer.elapsedTime() << "s \n";
} else {
timer.clear();
timer.start();
svmpack::SVMPredictor<SVMREAL> pred ( options );
pred.predict();
timer.stop();
cerr << "time to predict = " << timer.elapsedTime() << "s \n";
}
}