SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
CCSOSVM.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 Viktor Gal
8  * Copyright (C) 2008 Chun-Nam Yu
9  */
10 
11 #ifndef __CCSOSVM_H__
12 #define __CCSOSVM_H__
13 
14 #include <shogun/lib/config.h>
16 #include <shogun/base/DynArray.h>
17 
18 #ifdef USE_MOSEK
19 #include <mosek.h>
20 #endif
21 
22 namespace shogun
23 {
24 
29  enum EQPType
30  {
31  MOSEK=1,
33  };
34 
44  {
45  public:
47  CCCSOSVM();
48 
54 
56  virtual ~CCCSOSVM();
57 
59  inline virtual const char* get_name() const { return "CCSOSVM"; }
60 
66  {
67  REQUIRE(W.vlen == m_model->get_dim(), "Dimension of the initial "
68  "solution must match the model's dimension!\n");
69  m_w=W;
70  }
71 
76  inline void set_epsilon(float64_t eps)
77  {
78  m_eps = eps;
79  }
80 
85  inline float64_t get_epsilon() const
86  {
87  return m_eps;
88  }
89 
94  inline void set_C(float64_t C)
95  {
96  m_C = C;
97  }
98 
103  inline float64_t get_C() const
104  {
105  return m_C;
106  }
107 
112  inline void set_max_iter(index_t max_iter)
113  {
114  m_max_iter = max_iter;
115  }
116 
121  inline index_t get_max_iter() const
122  {
123  return m_max_iter;
124  }
125 
131  {
132  return m_primal_obj;
133  }
134 
139  inline float64_t get_max_rho() const
140  {
141  return m_max_rho;
142  }
143 
148  inline void set_max_rho(float64_t max_rho)
149  {
150  m_max_rho = max_rho;
151  }
152 
157  inline EQPType get_qp_type() const
158  {
159  return m_qp_type;
160  }
161 
166  inline void set_qp_type(EQPType type)
167  {
168  m_qp_type = type;
169  }
170 
176 
177  protected:
178  bool train_machine(CFeatures* data=NULL);
179 
180  private:
186  SGSparseVector<float64_t> find_cutting_plane(float64_t* margin);
187 
188  int32_t resize_cleanup(int32_t size_active, SGVector<int32_t>& idle, SGVector<float64_t>&alpha,
190  SGVector<float64_t>& proximal_rhs, float64_t ***ptr_G,
192 
193  int32_t mosek_qp_optimize(float64_t** G, float64_t* delta, float64_t* alpha, int32_t k, float64_t* dual_obj, float64_t rho);
194 
196  void init();
197 
198  private:
200  float64_t m_C;
202  float64_t m_eps;
204  float64_t m_primal_obj;
205  float64_t m_alpha_thrld;
206  float64_t m_max_rho;
207 
209  index_t m_max_iter;
211  index_t m_cleanup_check;
213  index_t m_idle_iter;
214 
216  EQPType m_qp_type;
217 #ifdef USE_MOSEK
218 
219  MSKenv_t m_msk_env;
220 #endif
221  };
222 }
223 
224 #endif
EMachineType
Definition: Machine.h:33
void set_epsilon(float64_t eps)
Definition: CCSOSVM.h:76
int32_t index_t
Definition: common.h:62
EQPType get_qp_type() const
Definition: CCSOSVM.h:157
#define REQUIRE(x,...)
Definition: SGIO.h:206
virtual int32_t get_dim() const =0
EQPType
Definition: CCSOSVM.h:29
CCSOSVM.
Definition: CCSOSVM.h:43
float64_t get_epsilon() const
Definition: CCSOSVM.h:85
void set_max_rho(float64_t max_rho)
Definition: CCSOSVM.h:148
index_t get_max_iter() const
Definition: CCSOSVM.h:121
bool train_machine(CFeatures *data=NULL)
Definition: CCSOSVM.cpp:192
index_t vlen
Definition: SGVector.h:494
void set_qp_type(EQPType type)
Definition: CCSOSVM.h:166
float64_t get_max_rho() const
Definition: CCSOSVM.h:139
Template Dynamic array class that creates an array that can be used like a list or an array...
Definition: DynArray.h:32
double float64_t
Definition: common.h:50
float64_t compute_primal_objective()
Definition: CCSOSVM.h:130
virtual ~CCCSOSVM()
Definition: CCSOSVM.cpp:40
Class CStructuredModel that represents the application specific model and contains most of the applic...
void set_w(SGVector< float64_t > W)
Definition: CCSOSVM.h:65
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
virtual EMachineType get_classifier_type()
Definition: CCSOSVM.cpp:721
void set_max_iter(index_t max_iter)
Definition: CCSOSVM.h:112
virtual const char * get_name() const
Definition: CCSOSVM.h:59
float64_t get_C() const
Definition: CCSOSVM.h:103
#define delta
Definition: sfa.cpp:23
void set_C(float64_t C)
Definition: CCSOSVM.h:94

SHOGUN 机器学习工具包 - 项目文档