SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SVMOcas.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) 2007-2009 Vojtech Franc
8  * Written (W) 2007-2009 Soeren Sonnenburg
9  * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _SVMOCAS_H___
13 #define _SVMOCAS_H___
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
19 #include <shogun/lib/external/libocas.h>
21 #include <shogun/labels/Labels.h>
22 
23 namespace shogun
24 {
25 #ifndef DOXYGEN_SHOULD_SKIP_THIS
26 enum E_SVM_TYPE
27 {
28  SVM_OCAS = 0,
29  SVM_BMRM = 1
30 };
31 #endif
32 
34 class CSVMOcas : public CLinearMachine
35 {
36  public:
37 
40 
42  CSVMOcas();
43 
48  CSVMOcas(E_SVM_TYPE type);
49 
56  CSVMOcas(
57  float64_t C, CDotFeatures* traindat,
58  CLabels* trainlab);
59  virtual ~CSVMOcas();
60 
66 
73  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
74 
79  inline float64_t get_C1() { return C1; }
80 
85  inline float64_t get_C2() { return C2; }
86 
91  inline void set_epsilon(float64_t eps) { epsilon=eps; }
92 
97  inline float64_t get_epsilon() { return epsilon; }
98 
103  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
104 
109  inline bool get_bias_enabled() { return use_bias; }
110 
115  inline void set_bufsize(int32_t sz) { bufsize=sz; }
116 
121  inline int32_t get_bufsize() { return bufsize; }
122 
127  virtual float64_t compute_primal_objective() const;
128 
129  protected:
138  static void compute_W(
139  float64_t *sq_norm_W, float64_t *dp_WoldW, float64_t *alpha,
140  uint32_t nSel, void* ptr);
141 
148  static float64_t update_W(float64_t t, void* ptr );
149 
158  static int add_new_cut(
159  float64_t *new_col_H, uint32_t *new_cut, uint32_t cut_length,
160  uint32_t nSel, void* ptr );
161 
167  static int compute_output( float64_t *output, void* ptr );
168 
175  static int sort( float64_t* vals, float64_t* data, uint32_t size);
176 
178  static inline void print(ocas_return_value_T value)
179  {
180  return;
181  }
182 
183  protected:
192  virtual bool train_machine(CFeatures* data=NULL);
193 
195  inline const char* get_name() const { return "SVMOcas"; }
196  private:
197  void init();
198 
199  protected:
201  bool use_bias;
203  int32_t bufsize;
211  E_SVM_TYPE method;
212 
221 
226  uint32_t** cp_index;
228  uint32_t* cp_nz_dims;
231 
234 };
235 }
236 #endif

SHOGUN Machine Learning Toolbox - Documentation