Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _NEWTONSVM_H___
00012 #define _NEWTONSVM_H___
00013
00014 #include <shogun/lib/common.h>
00015 #include <shogun/machine/LinearMachine.h>
00016 #include <shogun/features/DotFeatures.h>
00017 #include <shogun/labels/Labels.h>
00018
00019 namespace shogun
00020 {
00021 #ifdef HAVE_LAPACK
00022
00027 class CNewtonSVM : public CLinearMachine
00028 {
00029 public:
00030 MACHINE_PROBLEM_TYPE(PT_BINARY);
00031
00033 CNewtonSVM();
00034
00041 CNewtonSVM(float64_t C, CDotFeatures* traindat, CLabels* trainlab, int32_t itr=20);
00042
00043 virtual ~CNewtonSVM();
00044
00049 virtual EMachineType get_classifier_type() { return CT_NEWTONSVM; }
00050
00055 inline void set_C(float64_t c) { C=c; }
00056
00060 inline float64_t get_epsilon() { return epsilon; }
00061
00066 inline void set_epsilon(float64_t e) { epsilon=e; }
00067
00071 inline float64_t get_C() { return C; }
00072
00073
00077 inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00078
00082 inline bool get_bias_enabled() { return use_bias; }
00083
00087 inline int32_t get_num_iter() {return num_iter;}
00088
00092 inline void set_num_iter(int32_t iter) { num_iter=iter; }
00093
00095 virtual const char* get_name() const { return "NewtonSVM"; }
00096
00097 protected:
00106 virtual bool train_machine(CFeatures* data=NULL);
00107
00108 private:
00109 void obj_fun_linear(float64_t* weights, float64_t* out, float64_t* obj,
00110 int32_t* sv, int32_t* numsv, float64_t* grad);
00111
00112 void line_search_linear(float64_t* weights, float64_t* d,
00113 float64_t* out, float64_t* tx);
00114
00115 protected:
00117 float64_t lambda, C, epsilon;
00118 float64_t prec;
00119 int32_t x_n, x_d, num_iter;
00120
00122 bool use_bias;
00123 };
00124 #endif //HAVE_LAPACK
00125 }
00126 #endif //_NEWTONSVM_H___