himrep
SVMLinear.h
1 #include <iostream>
2 #include <string>
3 #include "linear.h"
4 #include <vector>
5 #include <fstream>
6 #include <malloc.h>
7 #include <string.h>
8 #include <stdlib.h>
9 #define Malloc(type,n) (type *)malloc((n)*sizeof(type))
10 
11 using namespace std;
12 
13 class SVMLinear
14 {
15  private:
16 
17  struct problem SVMProblem;
18  string className;
19 
20  public:
21  struct model* modelLinearSVM;
22  SVMLinear(string className);
23 
24  void trainModel(std::vector<std::vector<double> > &features, vector<double> &labels, parameter &param, int bias=1);
25  double predictModel(vector<double> features);
26  parameter initialiseParam(int solverTYPE=L2R_L2LOSS_SVC_DUAL, double C=1.0, double eps=0.1,int nClass=0, int nr_Positive=0, int nr_Negative=0);
27  void saveModel(string pathFile);
28  void loadModel(string pathFile);
29  vector<vector<double> > readFeatures(string filePath);
30  void freeModel() {};
31 
32 };