SHOGUN  v3.2.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
NewtonSVM.h
浏览该文件的文档.
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/common.h>
17 #include <shogun/labels/Labels.h>
18 
19 namespace shogun
20 {
21 #ifdef HAVE_LAPACK
22 
27 class CNewtonSVM : public CLinearMachine
28 {
29  public:
31 
33  CNewtonSVM();
34 
41  CNewtonSVM(float64_t C, CDotFeatures* traindat, CLabels* trainlab, int32_t itr=20);
42 
43  virtual ~CNewtonSVM();
44 
50 
55  inline void set_C(float64_t c) { C=c; }
56 
60  inline float64_t get_epsilon() { return epsilon; }
61 
66  inline void set_epsilon(float64_t e) { epsilon=e; }
67 
71  inline float64_t get_C() { return C; }
72 
73 
77  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
78 
82  inline bool get_bias_enabled() { return use_bias; }
83 
87  inline int32_t get_num_iter() {return num_iter;}
88 
92  inline void set_num_iter(int32_t iter) { num_iter=iter; }
93 
95  virtual const char* get_name() const { return "NewtonSVM"; }
96 
97  protected:
106  virtual bool train_machine(CFeatures* data=NULL);
107 
108  private:
109  void obj_fun_linear(float64_t* weights, float64_t* out, float64_t* obj,
110  int32_t* sv, int32_t* numsv, float64_t* grad);
111 
112  void line_search_linear(float64_t* weights, float64_t* d,
113  float64_t* out, float64_t* tx);
114 
115  protected:
119  int32_t x_n, x_d, num_iter;
120 
122  bool use_bias;
123 };
124 #endif //HAVE_LAPACK
125 }
126 #endif //_NEWTONSVM_H___
float64_t get_C()
Definition: NewtonSVM.h:71
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:92
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:35
void set_epsilon(float64_t e)
Definition: NewtonSVM.h:66
virtual EMachineType get_classifier_type()
Definition: NewtonSVM.h:49
void set_C(float64_t c)
Definition: NewtonSVM.h:55
float64_t lambda
Definition: NewtonSVM.h:117
Features that support dot products among other operations.
Definition: DotFeatures.h:41
void set_bias_enabled(bool enable_bias)
Definition: NewtonSVM.h:77
virtual ~CNewtonSVM()
Definition: NewtonSVM.cpp:44
bool get_bias_enabled()
Definition: NewtonSVM.h:82
double float64_t
Definition: common.h:48
Class LinearMachine is a generic interface for all kinds of linear machines like classifiers.
Definition: LinearMachine.h:61
float64_t prec
Definition: NewtonSVM.h:118
The class Features is the base class of all feature objects.
Definition: Features.h:62
int32_t get_num_iter()
Definition: NewtonSVM.h:87
float64_t epsilon
Definition: NewtonSVM.h:117
NewtonSVM, In this Implementation linear SVM is trained in its primal form using Newton-like iteratio...
Definition: NewtonSVM.h:27
virtual const char * get_name() const
Definition: NewtonSVM.h:95
float64_t get_epsilon()
Definition: NewtonSVM.h:60

SHOGUN Machine Learning Toolbox - Documentation