blob: 905134369dcd30cc0300c18f0daf71289a1cf3be (
plain)
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
|
#ifndef RANKSVM_H
#define RANKSVM_H
#include<Eigen/Dense>
#include<string>
#include<list>
#include"../tools/dataProvider.h"
#include "../tools/easylogging++.h"
// Model File:
// Model type -> String
// Number of features (fsize) -> int
// Weight matrix size, (fsize,1) -> (int,int)
// Weight vector
// beta
typedef struct SVMModel{
Eigen::VectorXd weight;
double beta;
} SVMModel;
class RSVM //Virtual base class for all RSVM operations
{
protected:
SVMModel model;
int fsize;
public:
virtual int train(RidList &D)=0;
virtual int predict(DataList &D,std::vector<double> &res)=0;
// TODO Not sure how to construct this
// Possible solution: generate a nxn matrix each row contains the sorted list of ranker result.
int saveModel(const std::string fname);
static RSVM* loadModel(const std::string fname);
virtual std::string getName()=0;
SVMModel getModel(){
return model;};
int setModel(const SVMModel &model);
};
extern double C;// Compensating & scaling
#endif
|