SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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
EMachineType
Definition: Machine.h:33
Class CLossFunction is the base class of all loss functions.
Definition: LossFunction.h:57
float64_t get_C2()
Definition: SVMSGD.h:88
bool get_bias_enabled()
Definition: SVMSGD.h:112
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
void set_epochs(int32_t e)
Definition: SVMSGD.h:94
void set_C(float64_t c_neg, float64_t c_pos)
Definition: SVMSGD.h:76
void calibrate()
Definition: SVMSGD.cpp:159
void set_bias_enabled(bool enable_bias)
Definition: SVMSGD.h:106
Features that support dot products among other operations.
Definition: DotFeatures.h:44
#define SG_REF(x)
Definition: SGObject.h:51
MACHINE_PROBLEM_TYPE(PT_BINARY)
int32_t get_epochs()
Definition: SVMSGD.h:100
float64_t get_C1()
Definition: SVMSGD.h:82
virtual bool train_machine(CFeatures *data=NULL)
Definition: SVMSGD.cpp:70
virtual EMachineType get_classifier_type()
Definition: SVMSGD.h:68
double float64_t
Definition: common.h:50
class SVMSGD
Definition: SVMSGD.h:36
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
Definition: LinearMachine.h:63
void set_regularized_bias_enabled(bool enable_bias)
Definition: SVMSGD.h:118
bool get_regularized_bias_enabled()
Definition: SVMSGD.h:124
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual const char * get_name() const
Definition: SVMSGD.h:139
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual ~CSVMSGD()
Definition: SVMSGD.cpp:58
void set_loss_function(CLossFunction *loss_func)
Definition: SVMSGD.cpp:63
CLossFunction * get_loss_function()
Definition: SVMSGD.h:136

SHOGUN Machine Learning Toolbox - Documentation