SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SVMSGD.h
Go to the documentation of this file.
1 #ifndef _SVMSGD_H___
2 #define _SVMSGD_H___
3 
4 /*
5  SVM with stochastic gradient
6  Copyright (C) 2007- Leon Bottou
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22  Shogun adjustments (w) 2008 Soeren Sonnenburg
23 */
24 
25 #include <shogun/lib/common.h>
28 #include <shogun/labels/Labels.h>
30 
31 namespace shogun
32 {
34 class CSVMSGD : public CLinearMachine
35 {
36  public:
37 
40 
42  CSVMSGD();
43 
48  CSVMSGD(float64_t C);
49 
56  CSVMSGD(
57  float64_t C, CDotFeatures* traindat,
58  CLabels* trainlab);
59 
60  virtual ~CSVMSGD();
61 
67 
74  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
75 
80  inline float64_t get_C1() { return C1; }
81 
86  inline float64_t get_C2() { return C2; }
87 
92  inline void set_epochs(int32_t e) { epochs=e; }
93 
98  inline int32_t get_epochs() { return epochs; }
99 
104  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
105 
110  inline bool get_bias_enabled() { return use_bias; }
111 
116  inline void set_regularized_bias_enabled(bool enable_bias) { use_regularized_bias=enable_bias; }
117 
122  inline bool get_regularized_bias_enabled() { return use_regularized_bias; }
123 
128  void set_loss_function(CLossFunction* loss_func);
129 
134  inline CLossFunction* get_loss_function() { SG_REF(loss); return loss; }
135 
137  virtual const char* get_name() const { return "SVMSGD"; }
138 
139  protected:
141  void calibrate();
142 
151  virtual bool train_machine(CFeatures* data=NULL);
152 
153  private:
154  void init();
155 
156  private:
157  float64_t t;
158  float64_t C1;
159  float64_t C2;
160  float64_t wscale;
161  float64_t bscale;
162  int32_t epochs;
163  int32_t skip;
164  int32_t count;
165 
166  bool use_bias;
167  bool use_regularized_bias;
168 
169  CLossFunction* loss;
170 };
171 }
172 #endif

SHOGUN Machine Learning Toolbox - Documentation