SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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
EMachineType
Definition: Machine.h:33
Class OnlineLinearMachine is a generic interface for linear machines like classifiers which work thro...
Class CLossFunction is the base class of all loss functions.
Definition: LossFunction.h:57
bool get_regularized_bias_enabled()
Definition: OnlineSVMSGD.h:141
virtual EMachineType get_classifier_type()
Definition: OnlineSVMSGD.h:63
void calibrate(int32_t max_vec_num=1000)
#define SG_REF(x)
Definition: SGObject.h:51
void set_lambda(float64_t l)
Definition: OnlineSVMSGD.h:111
void set_bias_enabled(bool enable_bias)
Definition: OnlineSVMSGD.h:123
void set_loss_function(CLossFunction *loss_func)
virtual bool train(CFeatures *data=NULL)
double float64_t
Definition: common.h:50
void set_C(float64_t c_neg, float64_t c_pos)
Definition: OnlineSVMSGD.h:81
float64_t get_lambda()
Definition: OnlineSVMSGD.h:117
void set_epochs(int32_t e)
Definition: OnlineSVMSGD.h:99
Streaming features that support dot products among other operations.
void set_regularized_bias_enabled(bool enable_bias)
Definition: OnlineSVMSGD.h:135
CLossFunction * get_loss_function()
Definition: OnlineSVMSGD.h:153
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
class OnlineSVMSGD
Definition: OnlineSVMSGD.h:35
const char * get_name() const
Definition: OnlineSVMSGD.h:156
MACHINE_PROBLEM_TYPE(PT_BINARY)

SHOGUN Machine Learning Toolbox - Documentation