SHOGUN  3.2.1
 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/config.h>
26 
27 #include <shogun/lib/common.h>
30 #include <shogun/labels/Labels.h>
32 
33 namespace shogun
34 {
36 class CSVMSGD : public CLinearMachine
37 {
38  public:
39 
42 
44  CSVMSGD();
45 
50  CSVMSGD(float64_t C);
51 
58  CSVMSGD(
59  float64_t C, CDotFeatures* traindat,
60  CLabels* trainlab);
61 
62  virtual ~CSVMSGD();
63 
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_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
107 
112  inline bool get_bias_enabled() { return use_bias; }
113 
118  inline void set_regularized_bias_enabled(bool enable_bias) { use_regularized_bias=enable_bias; }
119 
124  inline bool get_regularized_bias_enabled() { return use_regularized_bias; }
125 
130  void set_loss_function(CLossFunction* loss_func);
131 
136  inline CLossFunction* get_loss_function() { SG_REF(loss); return loss; }
137 
139  virtual const char* get_name() const { return "SVMSGD"; }
140 
141  protected:
143  void calibrate();
144 
153  virtual bool train_machine(CFeatures* data=NULL);
154 
155  private:
156  void init();
157 
158  private:
159  float64_t t;
160  float64_t C1;
161  float64_t C2;
162  float64_t wscale;
163  float64_t bscale;
164  int32_t epochs;
165  int32_t skip;
166  int32_t count;
167 
168  bool use_bias;
169  bool use_regularized_bias;
170 
171  CLossFunction* loss;
172 };
173 }
174 #endif

SHOGUN Machine Learning Toolbox - Documentation