SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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
void set_shrinking_enabled(bool enable)
Definition: SVM.h:179
bool use_shrinking
Definition: SVM.h:265
float64_t get_C2()
Definition: SVM.h:167
float64_t compute_svm_primal_objective()
Definition: SVM.cpp:267
int32_t qpsize
Definition: SVM.h:263
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
bool(* callback)(CMKL *mkl, const float64_t *sumw, const float64_t suma)
Definition: SVM.h:269
MACHINE_PROBLEM_TYPE(PT_BINARY)
virtual ~CSVM()
Definition: SVM.cpp:43
float64_t get_nu()
Definition: SVM.h:155
void set_callback_function(CMKL *m, bool(*cb)(CMKL *mkl, const float64_t *sumw, const float64_t suma))
Definition: SVM.cpp:232
float64_t get_tube_epsilon()
Definition: SVM.h:137
CMKL * mkl
Definition: SVM.h:272
virtual void set_linear_term(const SGVector< float64_t > linear_term)
Definition: SVM.cpp:314
A generic KernelMachine interface.
Definition: KernelMachine.h:51
float64_t epsilon
Definition: SVM.h:251
void set_nu(float64_t nue)
Definition: SVM.h:107
virtual const char * get_name() const
Definition: SVM.h:234
float64_t get_C1()
Definition: SVM.h:161
virtual float64_t * get_linear_term_array()
Definition: SVM.cpp:302
void set_defaults(int32_t num_sv=0)
Definition: SVM.cpp:48
SGVector< float64_t > m_linear_term
Definition: SVM.h:246
float64_t compute_svm_dual_objective()
Definition: SVM.cpp:242
class MultiClassSVM
Definition: MulticlassSVM.h:28
float64_t C2
Definition: SVM.h:259
bool get_shrinking_enabled()
Definition: SVM.h:188
double float64_t
Definition: common.h:50
void set_objective(float64_t v)
Definition: SVM.h:209
void set_qpsize(int32_t qps)
Definition: SVM.h:143
virtual SGVector< float64_t > get_linear_term()
Definition: SVM.cpp:332
float64_t C1
Definition: SVM.h:257
Multiple Kernel Learning.
Definition: MKL.h:85
float64_t objective
Definition: SVM.h:261
float64_t tube_epsilon
Definition: SVM.h:253
bool load(FILE *svm_file)
Definition: SVM.cpp:90
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
CSVM(int32_t num_sv=0)
Definition: SVM.cpp:28
A generic Support Vector Machine Interface.
Definition: SVM.h:49
bool save(FILE *svm_file)
Definition: SVM.cpp:206
The Kernel base class.
Definition: Kernel.h:159
bool svm_loaded
Definition: SVM.h:249
void set_epsilon(float64_t eps)
Definition: SVM.h:125
float64_t nu
Definition: SVM.h:255
int32_t get_qpsize()
Definition: SVM.h:173
float64_t get_epsilon()
Definition: SVM.h:149
float64_t get_objective()
Definition: SVM.h:218
void set_C(float64_t c_neg, float64_t c_pos)
Definition: SVM.h:118
void set_tube_epsilon(float64_t eps)
Definition: SVM.h:131

SHOGUN Machine Learning Toolbox - Documentation