SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OnlineSVMSGD.h
Go to the documentation of this file.
1 #ifndef _ONLINESVMSGD_H___
2 #define _ONLINESVMSGD_H___
3 /*
4  SVM with stochastic gradient
5  Copyright (C) 2007- Leon Bottou
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  Shogun adjustments (w) 2008 Soeren Sonnenburg
22 */
23 
24 #include <shogun/lib/common.h>
25 #include <shogun/labels/Labels.h>
29 
30 namespace shogun
31 {
34 {
35  public:
38 
40  COnlineSVMSGD();
41 
47 
54 
55  virtual ~COnlineSVMSGD();
56 
62 
71  virtual bool train(CFeatures* data=NULL);
72 
79  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
80 
85  inline float64_t get_C1() { return C1; }
86 
91  inline float64_t get_C2() { return C2; }
92 
97  inline void set_epochs(int32_t e) { epochs=e; }
98 
103  inline int32_t get_epochs() { return epochs; }
104 
109  inline void set_lambda(float64_t l) { lambda=l; }
110 
115  inline float64_t get_lambda() { return lambda; }
116 
121  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
122 
127  inline bool get_bias_enabled() { return use_bias; }
128 
133  inline void set_regularized_bias_enabled(bool enable_bias) { use_regularized_bias=enable_bias; }
134 
139  inline bool get_regularized_bias_enabled() { return use_regularized_bias; }
140 
145  void set_loss_function(CLossFunction* loss_func);
146 
151  inline CLossFunction* get_loss_function() { SG_REF(loss); return loss; }
152 
154  inline const char* get_name() const { return "OnlineSVMSGD"; }
155 
156  protected:
162  void calibrate(int32_t max_vec_num=1000);
163 
164  private:
165  void init();
166 
167  private:
168  float64_t t;
169  float64_t lambda;
170  float64_t C1;
171  float64_t C2;
172  float64_t wscale;
173  float64_t bscale;
174  int32_t epochs;
175  int32_t skip;
176  int32_t count;
177 
178  bool use_bias;
179  bool use_regularized_bias;
180 
181  CLossFunction* loss;
182 };
183 }
184 #endif

SHOGUN Machine Learning Toolbox - Documentation