SVMSGD.h

Go to the documentation of this file.
00001 #ifndef _SVMSGD_H___
00002 #define _SVMSGD_H___
00003 
00004 /*
00005    SVM with stochastic gradient
00006    Copyright (C) 2007- Leon Bottou
00007 
00008    This program is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 2.1 of the License, or (at your option) any later version.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
00021 
00022    Shogun adjustments (w) 2008 Soeren Sonnenburg
00023 */
00024 
00025 #include "lib/common.h"
00026 #include "classifier/SparseLinearClassifier.h"
00027 #include "features/SparseFeatures.h"
00028 #include "features/Labels.h"
00029 
00031 class CSVMSGD : public CSparseLinearClassifier
00032 {
00033     public:
00038         CSVMSGD(DREAL C);
00039 
00046         CSVMSGD(DREAL C, CSparseFeatures<DREAL>* traindat, CLabels* trainlab);
00047 
00048         ~CSVMSGD();
00049 
00054         virtual inline EClassifierType get_classifier_type() { return CT_SVMSGD; }
00055 
00060         virtual bool train();
00061 
00067         inline void set_C(DREAL c1, DREAL c2) { C1=c1; C2=c2; }
00068 
00073         inline DREAL get_C1() { return C1; }
00074 
00079         inline DREAL get_C2() { return C2; }
00080 
00085         inline void set_epochs(INT e) { epochs=e; }
00086 
00091         inline INT get_epochs() { return epochs; }
00092 
00097         inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00098 
00103         inline bool get_bias_enabled() { return use_bias; }
00104 
00109         inline void set_regularized_bias_enabled(bool enable_bias) { use_regularized_bias=enable_bias; }
00110 
00115         inline bool get_regularized_bias_enabled() { return use_regularized_bias; }
00116 
00117     protected:
00119         void calibrate();
00120 
00121     private:
00122         DREAL t;
00123         DREAL C1;
00124         DREAL C2;
00125         DREAL wscale;
00126         DREAL bscale;
00127         INT epochs;
00128         INT skip;
00129         INT count;
00130 
00131         bool use_bias;
00132         bool use_regularized_bias;
00133 };
00134 #endif

SHOGUN Machine Learning Toolbox - Documentation