BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
libsvmModel.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 //
5 
6 #ifndef LIBSVMMODELH
7 #define LIBSVMMODELH
8 
9 #ifndef SVRMODEL
10 #include <BALL/QSAR/svrModel.h>
11 #endif
12 
13 #include <fstream>
14 #include <svm.h>
15 
16 
17 namespace BALL
18 {
19  namespace QSAR
20  {
22  {
23  public:
27  LibsvmModel(const QSARData& q, int k_type, double p1, double p2=-1);
28 
29  virtual ~LibsvmModel();
31 
32 
36  void train();
37 
38  //RowVector predict(const vector<double>& substance, bool transform=1);
39 
40  void setParameters(vector<double>& v);
41 
42  virtual vector<double> getParameters() const;
44 
45 
46  private:
47 
48  // part of libsvm; unfortunately defined in svm.C instead of svm.h, so that we need this hack ...
49  struct svm_model
50  {
51  svm_parameter param; // parameter
52  int nr_class; // number of classes, = 2 in regression/one class svm
53  int l; // total #SV
54  svm_node **SV; // SVs (SV[l])
55  double **sv_coef; // coefficients for SVs in decision functions (sv_coef[k-1][l])
56  double *rho; // constants in decision functions (rho[k*(k-1)/2])
57  double *probA; // pariwise probability information
58  double *probB;
59 
60  // for classification only
61  int *label; // label of each class (label[k])
62  int *nSV; // number of SVs for each class (nSV[k])
63  // nSV[0] + nSV[1] + ... + nSV[k-1] = l
64  // XXX
65  int free_sv; // 1 if svm_model is created by svm_load_model
66  // 0 if svm_model is created by svm_train
67  };
68 
69  struct svm_problem* createProblem(int response_id);
70 
71  void createParameters();
72 
73  struct svm_model* svm_train_result_;
74 
75  struct svm_parameter parameters_;
76 
77  struct svm_node* x_space_;
78 
80  bool use_nu_;
81 
83  bool use_shrinking_;
84 
85  double nu_;
86  double p_;
87  double eps_;
88  double C_;
89 
90 
91  };
92  }
93 }
94 
95 
96 
97 #endif // LIBSVMMODELH
#define BALL_EXPORT
Definition: COMMON/global.h:50