SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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___
float64_t get_C()
Definition: NewtonSVM.h:73
EMachineType
Definition: Machine.h:33
virtual bool train_machine(CFeatures *data=NULL)
Definition: NewtonSVM.cpp:49
MACHINE_PROBLEM_TYPE(PT_BINARY)
void set_num_iter(int32_t iter)
Definition: NewtonSVM.h:94
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
void set_epsilon(float64_t e)
Definition: NewtonSVM.h:68
virtual EMachineType get_classifier_type()
Definition: NewtonSVM.h:51
void set_C(float64_t c)
Definition: NewtonSVM.h:57
float64_t lambda
Definition: NewtonSVM.h:119
Features that support dot products among other operations.
Definition: DotFeatures.h:44
void set_bias_enabled(bool enable_bias)
Definition: NewtonSVM.h:79
virtual ~CNewtonSVM()
Definition: NewtonSVM.cpp:44
bool get_bias_enabled()
Definition: NewtonSVM.h:84
double float64_t
Definition: common.h:50
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
Definition: LinearMachine.h:63
float64_t prec
Definition: NewtonSVM.h:120
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
int32_t get_num_iter()
Definition: NewtonSVM.h:89
float64_t epsilon
Definition: NewtonSVM.h:119
NewtonSVM, In this Implementation linear SVM is trained in its primal form using Newton-like iteratio...
Definition: NewtonSVM.h:29
virtual const char * get_name() const
Definition: NewtonSVM.h:97
float64_t get_epsilon()
Definition: NewtonSVM.h:62

SHOGUN Machine Learning Toolbox - Documentation