SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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/common.h>
19 #include <shogun/features/Labels.h>
20 
21 namespace shogun
22 {
23 #ifndef DOXYGEN_SHOULD_SKIP_THIS
24 enum E_SVM_TYPE
25 {
26  SVM_OCAS = 0,
27  SVM_BMRM = 1
28 };
29 #endif
30 
32 class CSVMOcas : public CLinearMachine
33 {
34  public:
36  CSVMOcas();
37 
42  CSVMOcas(E_SVM_TYPE type);
43 
50  CSVMOcas(
51  float64_t C, CDotFeatures* traindat,
52  CLabels* trainlab);
53  virtual ~CSVMOcas();
54 
59  virtual inline EClassifierType get_classifier_type() { return CT_SVMOCAS; }
60 
67  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
68 
73  inline float64_t get_C1() { return C1; }
74 
79  inline float64_t get_C2() { return C2; }
80 
85  inline void set_epsilon(float64_t eps) { epsilon=eps; }
86 
91  inline float64_t get_epsilon() { return epsilon; }
92 
97  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
98 
103  inline bool get_bias_enabled() { return use_bias; }
104 
109  inline void set_bufsize(int32_t sz) { bufsize=sz; }
110 
115  inline int32_t get_bufsize() { return bufsize; }
116 
117  protected:
126  static void compute_W(
127  float64_t *sq_norm_W, float64_t *dp_WoldW, float64_t *alpha,
128  uint32_t nSel, void* ptr);
129 
136  static float64_t update_W(float64_t t, void* ptr );
137 
146  static int add_new_cut(
147  float64_t *new_col_H, uint32_t *new_cut, uint32_t cut_length,
148  uint32_t nSel, void* ptr );
149 
155  static int compute_output( float64_t *output, void* ptr );
156 
163  static int sort( float64_t* vals, float64_t* data, uint32_t size);
164 
166  static inline void print(ocas_return_value_T value)
167  {
168  return;
169  }
170 
171  protected:
180  virtual bool train_machine(CFeatures* data=NULL);
181 
183  inline virtual const char* get_name() const { return "SVMOcas"; }
184  private:
185  void init();
186 
187  protected:
189  bool use_bias;
191  int32_t bufsize;
199  E_SVM_TYPE method;
200 
209 
214  uint32_t** cp_index;
216  uint32_t* cp_nz_dims;
219 };
220 }
221 #endif

SHOGUN Machine Learning Toolbox - Documentation