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 <shogun/lib/common.h>
00026 #include <shogun/machine/LinearMachine.h>
00027 #include <shogun/features/DotFeatures.h>
00028 #include <shogun/features/Labels.h>
00029 #include <shogun/loss/LossFunction.h>
00030 
00031 namespace shogun
00032 {
00034 class CSVMSGD : public CLinearMachine
00035 {
00036     public:
00038         CSVMSGD();
00039 
00044         CSVMSGD(float64_t C);
00045 
00052         CSVMSGD(
00053             float64_t C, CDotFeatures* traindat,
00054             CLabels* trainlab);
00055 
00056         virtual ~CSVMSGD();
00057 
00062         virtual inline EClassifierType get_classifier_type() { return CT_SVMSGD; }
00063 
00070         inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
00071 
00076         inline float64_t get_C1() { return C1; }
00077 
00082         inline float64_t get_C2() { return C2; }
00083 
00088         inline void set_epochs(int32_t e) { epochs=e; }
00089 
00094         inline int32_t get_epochs() { return epochs; }
00095 
00100         inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00101 
00106         inline bool get_bias_enabled() { return use_bias; }
00107 
00112         inline void set_regularized_bias_enabled(bool enable_bias) { use_regularized_bias=enable_bias; }
00113 
00118         inline bool get_regularized_bias_enabled() { return use_regularized_bias; }
00119 
00124         void set_loss_function(CLossFunction* loss_func);
00125 
00130         inline CLossFunction* get_loss_function() { SG_REF(loss); return loss; }
00131 
00133         inline virtual const char* get_name() const { return "SVMSGD"; }
00134 
00135     protected:
00137         void calibrate();
00138 
00147         virtual bool train_machine(CFeatures* data=NULL);
00148 
00149     private:
00150         void init();
00151 
00152     private:
00153         float64_t t;
00154         float64_t C1;
00155         float64_t C2;
00156         float64_t wscale;
00157         float64_t bscale;
00158         int32_t epochs;
00159         int32_t skip;
00160         int32_t count;
00161 
00162         bool use_bias;
00163         bool use_regularized_bias;
00164 
00165         CLossFunction* loss;
00166 };
00167 }
00168 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation