SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 
13 #ifndef _SVMOCAS_H___
14 #define _SVMOCAS_H___
15 
16 #include <shogun/lib/config.h>
17 #ifdef USE_GPL_SHOGUN
18 
19 #include <shogun/lib/common.h>
21 #include <shogun/lib/external/libocas.h>
23 #include <shogun/labels/Labels.h>
24 
25 namespace shogun
26 {
27 #ifndef DOXYGEN_SHOULD_SKIP_THIS
28 enum E_SVM_TYPE
29 {
30  SVM_OCAS = 0,
31  SVM_BMRM = 1
32 };
33 #endif
34 
36 class CSVMOcas : public CLinearMachine
37 {
38  public:
39 
42 
44  CSVMOcas();
45 
50  CSVMOcas(E_SVM_TYPE type);
51 
58  CSVMOcas(
59  float64_t C, CDotFeatures* traindat,
60  CLabels* trainlab);
61  virtual ~CSVMOcas();
62 
67  virtual EMachineType get_classifier_type() { return CT_SVMOCAS; }
68 
75  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
76 
81  inline float64_t get_C1() { return C1; }
82 
87  inline float64_t get_C2() { return C2; }
88 
93  inline void set_epsilon(float64_t eps) { epsilon=eps; }
94 
99  inline float64_t get_epsilon() { return epsilon; }
100 
105  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
106 
111  inline bool get_bias_enabled() { return use_bias; }
112 
117  inline void set_bufsize(int32_t sz) { bufsize=sz; }
118 
123  inline int32_t get_bufsize() { return bufsize; }
124 
129  virtual float64_t compute_primal_objective() const;
130 
131  protected:
140  static void compute_W(
141  float64_t *sq_norm_W, float64_t *dp_WoldW, float64_t *alpha,
142  uint32_t nSel, void* ptr);
143 
150  static float64_t update_W(float64_t t, void* ptr );
151 
160  static int add_new_cut(
161  float64_t *new_col_H, uint32_t *new_cut, uint32_t cut_length,
162  uint32_t nSel, void* ptr );
163 
169  static int compute_output( float64_t *output, void* ptr );
170 
177  static int sort( float64_t* vals, float64_t* data, uint32_t size);
178 
180  static inline void print(ocas_return_value_T value)
181  {
182  return;
183  }
184 
185  protected:
194  virtual bool train_machine(CFeatures* data=NULL);
195 
197  inline const char* get_name() const { return "SVMOcas"; }
198  private:
199  void init();
200 
201  protected:
203  bool use_bias;
205  int32_t bufsize;
207  float64_t C1;
209  float64_t C2;
211  float64_t epsilon;
213  E_SVM_TYPE method;
214 
216  float64_t* old_w;
218  float64_t old_bias;
220  float64_t* tmp_a_buf;
222  SGVector<float64_t> lab;
223 
226  float64_t** cp_value;
228  uint32_t** cp_index;
230  uint32_t* cp_nz_dims;
232  float64_t* cp_bias;
233 
235  float64_t primal_objective;
236 };
237 }
238 #endif
239 
240 #endif //USE_GPL_SHOGUN
EMachineType
Definition: Machine.h:33
void print(CJLCoverTreePoint &p)
#define MACHINE_PROBLEM_TYPE(PT)
Definition: Machine.h:120
double float64_t
Definition: common.h:50
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
void set_epsilon(float *begin, float max)
Definition: JLCoverTree.h:513

SHOGUN Machine Learning Toolbox - Documentation