SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SubGradientSVM.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 Soeren Sonnenburg
8  * Written (W) 2007-2008 Vojtech Franc
9  * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _SUBGRADIENTSVM_H___
13 #define _SUBGRADIENTSVM_H___
14 
15 #include <shogun/lib/common.h>
18 #include <shogun/features/Labels.h>
19 
20 namespace shogun
21 {
24 {
25  public:
28 
36  float64_t C, CDotFeatures* traindat,
37  CLabels* trainlab);
38  virtual ~CSubGradientSVM();
39 
45 
51  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
52 
53 
58  inline float64_t get_C1() { return C1; }
59 
64  inline float64_t get_C2() { return C2; }
65 
70  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
71 
76  inline bool get_bias_enabled() { return use_bias; }
77 
82  inline void set_epsilon(float64_t eps) { epsilon=eps; }
83 
88  inline float64_t get_epsilon() { return epsilon; }
89 
94  inline void set_qpsize(int32_t q) { qpsize=q; }
95 
100  inline int32_t get_qpsize() { return qpsize; }
101 
106  inline void set_qpsize_max(int32_t q) { qpsize_max=q; }
107 
112  inline int32_t get_qpsize_max() { return qpsize_max; }
113 
114  protected:
117  int32_t find_active(
118  int32_t num_feat, int32_t num_vec, int32_t& num_active,
119  int32_t& num_bound);
120 
123  void update_active(int32_t num_feat, int32_t num_vec);
124 
126  float64_t compute_objective(int32_t num_feat, int32_t num_vec);
127 
131  int32_t num_feat, int32_t num_vec, int32_t num_active,
132  int32_t num_bound);
133 
135  float64_t line_search(int32_t num_feat, int32_t num_vec);
136 
138  void compute_projection(int32_t num_feat, int32_t num_vec);
139 
141  void update_projection(float64_t alpha, int32_t num_vec);
142 
144  void init(int32_t num_vec, int32_t num_feat);
145 
147  void cleanup();
148 
150  inline virtual const char* get_name() const { return "SubGradientSVM"; }
151 
152  protected:
161  virtual bool train_machine(CFeatures* data=NULL);
162 
163  protected:
175  int32_t qpsize;
177  int32_t qpsize_max;
179  int32_t qpsize_limit;
181  bool use_bias;
182 
187 
188  //idx vectors of length num_vec
190  uint8_t* active;
192  uint8_t* old_active;
194  int32_t* idx_active;
196  int32_t* idx_bound;
198  int32_t delta_active;
200  int32_t delta_bound;
206  int32_t* tmp_proj_idx;
207 
208  //vector of length num_feat
217 
218  //vector of length num_feat
228  int32_t* hinge_idx;
229 
230  //vectors/sym matrix of size qpsize_limit
243 
246 };
247 }
248 #endif

SHOGUN Machine Learning Toolbox - Documentation