SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MulticlassSVM.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) 1999-2011 Soeren Sonnenburg
8  * Written (W) 2012 Soeren Sonnenburg, Chiyuan Zhang
9  * Copyright (C) 1999-2011 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _MULTICLASSSVM_H___
13 #define _MULTICLASSSVM_H___
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
21 
22 namespace shogun
23 {
24 
25 class CSVM;
26 
29 {
30  public:
33 
36 
42 
51  CMulticlassStrategy *strategy, float64_t C, CKernel* k, CLabels* lab);
52  virtual ~CMulticlassSVM();
53 
61  bool create_multiclass_svm(int32_t num_classes);
62 
69  bool set_svm(int32_t num, CSVM* svm);
70 
76  CSVM* get_svm(int32_t num)
77  {
78  return dynamic_cast<CSVM *>(m_machines->get_element_safe(num));
79  }
80 
84  bool load(FILE* svm_file);
85 
89  bool save(FILE* svm_file);
90 
91  // TODO remove if unnecessary here
96  // TODO remove if unnecessary here
101  // TODO remove if unnecessary here
106  // TODO remove if unnecessary here
110  float64_t get_nu() { return svm_proto()->get_nu(); }
111  // TODO remove if unnecessary here
115  float64_t get_C() { return m_C; }
116  // TODO remove if unnecessary here
120  int32_t get_qpsize() { return svm_proto()->get_qpsize(); }
121  // TODO remove if unnecessary here
126  // TODO remove if unnecessary here
131 
132  // TODO remove if unnecessary here
137  // TODO remove if unnecessary here
142  // TODO remove if unnecessary here
147 
148  // TODO remove if unnecessary here
152  void set_defaults(int32_t num_sv=0) { svm_proto()->set_defaults(num_sv); }
153  // TODO remove if unnecessary here
157  void set_linear_term(SGVector<float64_t> linear_term) { svm_proto()->set_linear_term(linear_term); }
158  // TODO remove if unnecessary here
162  void set_C(float64_t C) { svm_proto()->set_C(C,C); m_C = C; }
163  // TODO remove if unnecessary here
168  // TODO remove if unnecessary here
172  void set_nu(float64_t nue) { svm_proto()->set_nu(nue); }
173  // TODO remove if unnecessary here
178  // TODO remove if unnecessary here
182  void set_qpsize(int32_t qps) { svm_proto()->set_qpsize(qps); }
183  // TODO remove if unnecessary here
187  void set_shrinking_enabled(bool enable) { svm_proto()->set_shrinking_enabled(enable); }
188  // TODO remove if unnecessary here
193  // TODO remove if unnecessary here
197  void set_bias_enabled(bool enable_bias) { svm_proto()->set_bias_enabled(enable_bias); }
198  // TODO remove if unnecessary here
202  void set_linadd_enabled(bool enable) { svm_proto()->set_linadd_enabled(enable); }
203  // TODO remove if unnecessary here
208 
210  virtual const char* get_name() const
211  {
212  return "MulticlassSVM";
213  }
214 
215  protected:
216 
219  {
220  return dynamic_cast<CSVM*>(m_machine);
221  }
224  {
225  return svm_proto()->m_svs;
226  }
227 
229  virtual bool init_machines_for_apply(CFeatures* data);
230 
232  virtual bool is_acceptable_machine(CMachine *machine)
233  {
234  CSVM *svm = dynamic_cast<CSVM*>(machine);
235  if (svm == NULL)
236  return false;
237  return true;
238  }
239 
240  private:
241 
242  void init();
243 
244  protected:
245 
248 };
249 }
250 #endif
void set_epsilon(float64_t eps)
void set_shrinking_enabled(bool enable)
Definition: SVM.h:179
SGVector< int32_t > m_svs
void set_bias_enabled(bool enable_bias)
bool get_batch_computation_enabled()
void set_defaults(int32_t num_sv=0)
MACHINE_PROBLEM_TYPE(PT_MULTICLASS)
void set_qpsize(int32_t qps)
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
bool load(FILE *svm_file)
void set_shrinking_enabled(bool enable)
float64_t get_nu()
Definition: SVM.h:155
virtual bool init_machines_for_apply(CFeatures *data)
float64_t get_tube_epsilon()
Definition: SVM.h:137
virtual void set_linear_term(const SGVector< float64_t > linear_term)
Definition: SVM.cpp:314
A generic learning machine interface.
Definition: Machine.h:143
void set_nu(float64_t nue)
Definition: SVM.h:107
SGVector< int32_t > svm_svs()
void set_defaults(int32_t num_sv=0)
Definition: SVM.cpp:48
void set_linear_term(SGVector< float64_t > linear_term)
class MultiClassSVM
Definition: MulticlassSVM.h:28
void set_batch_computation_enabled(bool enable)
void set_objective(float64_t v)
void set_batch_computation_enabled(bool enable)
void set_nu(float64_t nue)
bool get_shrinking_enabled()
Definition: SVM.h:188
double float64_t
Definition: common.h:50
void set_C(float64_t C)
void set_objective(float64_t v)
Definition: SVM.h:209
void set_qpsize(int32_t qps)
Definition: SVM.h:143
virtual SGVector< float64_t > get_linear_term()
Definition: SVM.cpp:332
bool save(FILE *svm_file)
void set_tube_epsilon(float64_t eps)
virtual const char * get_name() const
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
CSGObject * get_element_safe(int32_t index) const
float64_t get_tube_epsilon()
The class Features is the base class of all feature objects.
Definition: Features.h:68
void set_linadd_enabled(bool enable)
bool create_multiclass_svm(int32_t num_classes)
virtual bool is_acceptable_machine(CMachine *machine)
A generic Support Vector Machine Interface.
Definition: SVM.h:49
void set_linadd_enabled(bool enable)
The Kernel base class.
Definition: Kernel.h:159
void set_bias_enabled(bool enable_bias)
class MulticlassStrategy used to construct generic multiclass classifiers with ensembles of binary cl...
void set_epsilon(float64_t eps)
Definition: SVM.h:125
bool set_svm(int32_t num, CSVM *svm)
int32_t get_qpsize()
Definition: SVM.h:173
float64_t get_epsilon()
Definition: SVM.h:149
float64_t get_objective()
Definition: SVM.h:218
SGVector< float64_t > get_linear_term()
Definition: MulticlassSVM.h:95
void set_C(float64_t c_neg, float64_t c_pos)
Definition: SVM.h:118
CSVM * get_svm(int32_t num)
Definition: MulticlassSVM.h:76
void set_tube_epsilon(float64_t eps)
Definition: SVM.h:131

SHOGUN Machine Learning Toolbox - Documentation