SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SVM.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _SVM_H___
12 #define _SVM_H___
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/lib/common.h>
18 #include <shogun/kernel/Kernel.h>
20 
21 namespace shogun
22 {
23 
24 class CMKL;
25 class CMulticlassSVM;
26 
49 class CSVM : public CKernelMachine
50 {
51  public:
52 
55 
59  CSVM(int32_t num_sv=0);
60 
68  CSVM(float64_t C, CKernel* k, CLabels* lab);
69 
70  virtual ~CSVM();
71 
74  void set_defaults(int32_t num_sv=0);
75 
76 
83 
84 
90  virtual void set_linear_term(const SGVector<float64_t> linear_term);
91 
92 
96  bool load(FILE* svm_file);
97 
101  bool save(FILE* svm_file);
102 
107  inline void set_nu(float64_t nue) { nu=nue; }
108 
109 
118  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
119 
120 
125  inline void set_epsilon(float64_t eps) { epsilon=eps; }
126 
131  inline void set_tube_epsilon(float64_t eps) { tube_epsilon=eps; }
132 
138 
143  inline void set_qpsize(int32_t qps) { qpsize=qps; }
144 
149  inline float64_t get_epsilon() { return epsilon; }
150 
155  inline float64_t get_nu() { return nu; }
156 
161  inline float64_t get_C1() { return C1; }
162 
167  inline float64_t get_C2() { return C2; }
168 
173  inline int32_t get_qpsize() { return qpsize; }
174 
179  inline void set_shrinking_enabled(bool enable)
180  {
181  use_shrinking=enable;
182  }
183 
188  inline bool get_shrinking_enabled()
189  {
190  return use_shrinking;
191  }
192 
198 
204 
209  inline void set_objective(float64_t v)
210  {
211  objective=v;
212  }
213 
219  {
220  return objective;
221  }
222 
230  void set_callback_function(CMKL* m, bool (*cb)
231  (CMKL* mkl, const float64_t* sumw, const float64_t suma));
232 
234  virtual const char* get_name() const { return "SVM"; }
235 
236  protected:
237 
243  virtual float64_t* get_linear_term_array();
244 
247 
263  int32_t qpsize;
266 
269  bool (*callback) (CMKL* mkl, const float64_t* sumw, const float64_t suma);
273 
274  friend class CMulticlassSVM;
275 };
276 }
277 #endif

SHOGUN Machine Learning Toolbox - Documentation