SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NewtonSVM.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2012 Harshit Syal
8  * Copyright (C) 2012 Harshit Syal
9  */
10 
11 #ifndef _NEWTONSVM_H___
12 #define _NEWTONSVM_H___
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/lib/common.h>
19 #include <shogun/labels/Labels.h>
20 
21 namespace shogun
22 {
23 #ifdef HAVE_LAPACK
24 
29 class CNewtonSVM : public CLinearMachine
30 {
31  public:
33 
35  CNewtonSVM();
36 
43  CNewtonSVM(float64_t C, CDotFeatures* traindat, CLabels* trainlab, int32_t itr=20);
44 
45  virtual ~CNewtonSVM();
46 
52 
57  inline void set_C(float64_t c) { C=c; }
58 
62  inline float64_t get_epsilon() { return epsilon; }
63 
68  inline void set_epsilon(float64_t e) { epsilon=e; }
69 
73  inline float64_t get_C() { return C; }
74 
75 
79  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
80 
84  inline bool get_bias_enabled() { return use_bias; }
85 
89  inline int32_t get_num_iter() {return num_iter;}
90 
94  inline void set_num_iter(int32_t iter) { num_iter=iter; }
95 
97  virtual const char* get_name() const { return "NewtonSVM"; }
98 
99  protected:
108  virtual bool train_machine(CFeatures* data=NULL);
109 
110  private:
111  void obj_fun_linear(float64_t* weights, float64_t* out, float64_t* obj,
112  int32_t* sv, int32_t* numsv, float64_t* grad);
113 
114  void line_search_linear(float64_t* weights, float64_t* d,
115  float64_t* out, float64_t* tx);
116 
117  protected:
121  int32_t x_n, x_d, num_iter;
122 
124  bool use_bias;
125 };
126 #endif //HAVE_LAPACK
127 }
128 #endif //_NEWTONSVM_H___

SHOGUN Machine Learning Toolbox - Documentation