SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MulticlassOCAS.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 Sergey Lisitsyn
8  * Copyright (C) 2012 Sergey Lisitsyn
9  */
10 
11 
12 #ifndef _MULTICLASSOCAS_H___
13 #define _MULTICLASSOCAS_H___
14 
15 #include <shogun/lib/config.h>
16 #ifdef USE_GPL_SHOGUN
17 
18 #include <shogun/lib/common.h>
20 #include <shogun/lib/external/libocas.h>
22 
23 namespace shogun
24 {
25 
27 class CMulticlassOCAS : public CLinearMulticlassMachine
28 {
29  public:
31 
32 
33  CMulticlassOCAS();
34 
40  CMulticlassOCAS(float64_t C, CDotFeatures* features, CLabels* labs);
41 
43  virtual ~CMulticlassOCAS();
44 
46  virtual const char* get_name() const
47  {
48  return "MulticlassOCAS";
49  }
50 
54  inline void set_C(float64_t C)
55  {
56  ASSERT(C>0)
57  m_C = C;
58  }
62  inline float64_t get_C() const { return m_C; }
63 
67  inline void set_epsilon(float64_t epsilon)
68  {
69  ASSERT(epsilon>0)
70  m_epsilon = epsilon;
71  }
75  inline float64_t get_epsilon() const { return m_epsilon; }
76 
80  inline void set_max_iter(int32_t max_iter)
81  {
82  ASSERT(max_iter>0)
83  m_max_iter = max_iter;
84  }
88  inline int32_t get_max_iter() const { return m_max_iter; }
89 
93  inline void set_method(int32_t method)
94  {
95  ASSERT(method==0 || method==1)
96  m_method = method;
97  }
101  inline int32_t get_method() const { return m_method; }
102 
106  inline void set_buf_size(int32_t buf_size)
107  {
108  ASSERT(buf_size>0)
109  m_buf_size = buf_size;
110  }
114  inline int32_t get_buf_size() const { return m_buf_size; }
115 
116 protected:
117 
119  virtual bool train_machine(CFeatures* data = NULL);
120 
122  static float64_t msvm_update_W(float64_t t, void* user_data);
123 
125  static void msvm_full_compute_W(float64_t *sq_norm_W, float64_t *dp_WoldW,
126  float64_t *alpha, uint32_t nSel, void* user_data);
127 
129  static int msvm_full_add_new_cut(float64_t *new_col_H, uint32_t *new_cut,
130  uint32_t nSel, void* user_data);
131 
133  static int msvm_full_compute_output(float64_t *output, void* user_data);
134 
136  static int msvm_sort_data(float64_t* vals, float64_t* data, uint32_t size);
137 
139  static void msvm_print(ocas_return_value_T value);
140 
141 private:
142 
144  void register_parameters();
145 
146 protected:
147 
149  float64_t m_C;
150 
152  float64_t m_epsilon;
153 
155  int32_t m_max_iter;
156 
158  int32_t m_method;
159 
161  int32_t m_buf_size;
162 };
163 }
164 #endif
165 
166 #endif
#define ASSERT(x)
Definition: SGIO.h:201
#define MACHINE_PROBLEM_TYPE(PT)
Definition: Machine.h:120
double float64_t
Definition: common.h:50
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
void set_epsilon(float *begin, float max)
Definition: JLCoverTree.h:513

SHOGUN Machine Learning Toolbox - Documentation