SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
20 
21  Shogun adjustments (w) 2008 Soeren Sonnenburg
22 */
23 
24 #include <shogun/lib/common.h>
25 #include <shogun/features/Labels.h>
29 
30 namespace shogun
31 {
34 {
35  public:
37  COnlineSVMSGD();
38 
44 
51 
52  virtual ~COnlineSVMSGD();
53 
58  virtual inline EClassifierType get_classifier_type() { return CT_SVMSGD; }
59 
68  virtual bool train(CFeatures* data=NULL);
69 
76  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
77 
82  inline float64_t get_C1() { return C1; }
83 
88  inline float64_t get_C2() { return C2; }
89 
94  inline void set_epochs(int32_t e) { epochs=e; }
95 
100  inline int32_t get_epochs() { return epochs; }
101 
106  inline void set_lambda(float64_t l) { lambda=l; }
107 
112  inline float64_t get_lambda() { return lambda; }
113 
118  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
119 
124  inline bool get_bias_enabled() { return use_bias; }
125 
130  inline void set_regularized_bias_enabled(bool enable_bias) { use_regularized_bias=enable_bias; }
131 
136  inline bool get_regularized_bias_enabled() { return use_regularized_bias; }
137 
142  void set_loss_function(CLossFunction* loss_func);
143 
148  inline CLossFunction* get_loss_function() { SG_REF(loss); return loss; }
149 
151  inline virtual const char* get_name() const { return "OnlineSVMSGD"; }
152 
153  protected:
159  void calibrate(int32_t max_vec_num=1000);
160 
161  private:
162  void init();
163 
164  private:
165  float64_t t;
166  float64_t lambda;
167  float64_t C1;
168  float64_t C2;
169  float64_t wscale;
170  float64_t bscale;
171  int32_t epochs;
172  int32_t skip;
173  int32_t count;
174 
175  bool use_bias;
176  bool use_regularized_bias;
177 
178  CLossFunction* loss;
179 };
180 }
181 #endif

SHOGUN Machine Learning Toolbox - Documentation