SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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/common.h>
19 
20 namespace shogun
21 {
22 
23 class CSVM;
24 
27 {
28  public:
31 
34 
40 
49  CMulticlassStrategy *strategy, float64_t C, CKernel* k, CLabels* lab);
50  virtual ~CMulticlassSVM();
51 
59  bool create_multiclass_svm(int32_t num_classes);
60 
67  bool set_svm(int32_t num, CSVM* svm);
68 
74  CSVM* get_svm(int32_t num)
75  {
76  return dynamic_cast<CSVM *>(m_machines->get_element_safe(num));
77  }
78 
82  bool load(FILE* svm_file);
83 
87  bool save(FILE* svm_file);
88 
89  // TODO remove if unnecessary here
94  // TODO remove if unnecessary here
99  // TODO remove if unnecessary here
104  // TODO remove if unnecessary here
108  float64_t get_nu() { return svm_proto()->get_nu(); }
109  // TODO remove if unnecessary here
113  float64_t get_C() { return m_C; }
114  // TODO remove if unnecessary here
118  int32_t get_qpsize() { return svm_proto()->get_qpsize(); }
119  // TODO remove if unnecessary here
124  // TODO remove if unnecessary here
129 
130  // TODO remove if unnecessary here
135  // TODO remove if unnecessary here
140  // TODO remove if unnecessary here
145 
146  // TODO remove in unnecessary here
150  void set_defaults(int32_t num_sv=0) { svm_proto()->set_defaults(num_sv); }
151  // TODO remove in unnecessary here
155  void set_linear_term(SGVector<float64_t> linear_term) { svm_proto()->set_linear_term(linear_term); }
156  // TODO remove in unnecessary here
160  void set_C(float64_t C) { svm_proto()->set_C(C,C); m_C = C; }
161  // TODO remove in unnecessary here
166  // TODO remove in unnecessary here
170  void set_nu(float64_t nue) { svm_proto()->set_nu(nue); }
171  // TODO remove in unnecessary here
176  // TODO remove in unnecessary here
180  void set_qpsize(int32_t qps) { svm_proto()->set_qpsize(qps); }
181  // TODO remove in unnecessary here
185  void set_shrinking_enabled(bool enable) { svm_proto()->set_shrinking_enabled(enable); }
186  // TODO remove in unnecessary here
191  // TODO remove in unnecessary here
195  void set_bias_enabled(bool enable_bias) { svm_proto()->set_bias_enabled(enable_bias); }
196  // TODO remove in unnecessary here
200  void set_linadd_enabled(bool enable) { svm_proto()->set_linadd_enabled(enable); }
201  // TODO remove in unnecessary here
206 
207  protected:
208 
211  {
212  return dynamic_cast<CSVM*>(m_machine);
213  }
216  {
217  return svm_proto()->m_svs;
218  }
219 
221  virtual bool init_machines_for_apply(CFeatures* data);
222 
224  virtual bool is_acceptable_machine(CMachine *machine)
225  {
226  CSVM *svm = dynamic_cast<CSVM*>(machine);
227  if (svm == NULL)
228  return false;
229  return true;
230  }
231 
232  private:
233 
234  void init();
235 
236  protected:
237 
240 };
241 }
242 #endif

SHOGUN Machine Learning Toolbox - Documentation