SHOGUN  3.2.1
 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/config.h>
25 
26 #include <shogun/lib/common.h>
27 #include <shogun/labels/Labels.h>
31 
32 namespace shogun
33 {
36 {
37  public:
40 
42  COnlineSVMSGD();
43 
49 
56 
57  virtual ~COnlineSVMSGD();
58 
64 
73  virtual bool train(CFeatures* data=NULL);
74 
81  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
82 
87  inline float64_t get_C1() { return C1; }
88 
93  inline float64_t get_C2() { return C2; }
94 
99  inline void set_epochs(int32_t e) { epochs=e; }
100 
105  inline int32_t get_epochs() { return epochs; }
106 
111  inline void set_lambda(float64_t l) { lambda=l; }
112 
117  inline float64_t get_lambda() { return lambda; }
118 
123  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
124 
129  inline bool get_bias_enabled() { return use_bias; }
130 
135  inline void set_regularized_bias_enabled(bool enable_bias) { use_regularized_bias=enable_bias; }
136 
141  inline bool get_regularized_bias_enabled() { return use_regularized_bias; }
142 
147  void set_loss_function(CLossFunction* loss_func);
148 
153  inline CLossFunction* get_loss_function() { SG_REF(loss); return loss; }
154 
156  inline const char* get_name() const { return "OnlineSVMSGD"; }
157 
158  protected:
164  void calibrate(int32_t max_vec_num=1000);
165 
166  private:
167  void init();
168 
169  private:
170  float64_t t;
171  float64_t lambda;
172  float64_t C1;
173  float64_t C2;
174  float64_t wscale;
175  float64_t bscale;
176  int32_t epochs;
177  int32_t skip;
178  int32_t count;
179 
180  bool use_bias;
181  bool use_regularized_bias;
182 
183  CLossFunction* loss;
184 };
185 }
186 #endif

SHOGUN Machine Learning Toolbox - Documentation