SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MulticlassStrategy.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 Chiyuan Zhang
8  * Written (W) 2013 Shell Hu and Heiko Strathmann
9  * Copyright (C) 2012 Chiyuan Zhang
10  */
11 
12 #ifndef MULTICLASSSTRATEGY_H__
13 #define MULTICLASSSTRATEGY_H__
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/base/SGObject.h>
22 
23 namespace shogun
24 {
25 
37 {
39  OVA_NORM = 1,
41  OVO_PRICE = 3,
44 };
45 
50 {
51 public:
54 
59 
61  virtual ~CMulticlassStrategy() {}
62 
64  virtual const char* get_name() const
65  {
66  return "MulticlassStrategy";
67  };
68 
70  void set_num_classes(int32_t num_classes)
71  {
72  m_num_classes = num_classes;
73  }
74 
76  int32_t get_num_classes() const
77  {
78  return m_num_classes;
79  }
80 
83  {
85  return m_rejection_strategy;
86  }
87 
89  void set_rejection_strategy(CRejectionStrategy *rejection_strategy)
90  {
91  SG_REF(rejection_strategy);
93  m_rejection_strategy = rejection_strategy;
94  }
95 
97  virtual void train_start(CMulticlassLabels *orig_labels, CBinaryLabels *train_labels);
98 
100  virtual bool train_has_more()=0;
101 
106 
108  virtual void train_stop();
109 
113  virtual int32_t decide_label(SGVector<float64_t> outputs)=0;
114 
120  {
122  return SGVector<index_t>();
123  }
124 
127  virtual int32_t get_num_machines()=0;
128 
131  {
132  return m_prob_heuris;
133  }
134 
139  {
140  m_prob_heuris = prob_heuris;
141  }
142 
148  virtual void rescale_outputs(SGVector<float64_t> outputs)
149  {
151  }
152 
160  virtual void rescale_outputs(SGVector<float64_t> outputs,
161  const SGVector<float64_t> As, const SGVector<float64_t> Bs)
162  {
164  }
165 
166 private:
168  void init();
169 
170 protected:
171 
175  int32_t m_train_iter;
176  int32_t m_num_classes;
178 };
179 
180 } // namespace shogun
181 
182 #endif /* end of include guard: MULTICLASSSTRATEGY_H__ */
183 
CMulticlassLabels * m_orig_labels
original multiclass labels
virtual void rescale_outputs(SGVector< float64_t > outputs, const SGVector< float64_t > As, const SGVector< float64_t > Bs)
virtual void rescale_outputs(SGVector< float64_t > outputs)
#define SG_NOTIMPLEMENTED
Definition: SGIO.h:139
CRejectionStrategy * m_rejection_strategy
rejection strategy
CRejectionStrategy * get_rejection_strategy()
void set_prob_heuris_type(EProbHeuristicType prob_heuris)
#define SG_REF(x)
Definition: SGObject.h:54
int32_t m_num_classes
number of classes in this problem
Multiclass Labels for multi-class classification.
EProbHeuristicType m_prob_heuris
prob output heuristic
int32_t m_train_iter
index of current iterations
void set_num_classes(int32_t num_classes)
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
virtual int32_t get_num_machines()=0
base rejection strategy class
virtual const char * get_name() const
#define SG_UNREF(x)
Definition: SGObject.h:55
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
CBinaryLabels * m_train_labels
labels used to train the submachines
void set_rejection_strategy(CRejectionStrategy *rejection_strategy)
Binary Labels for binary classification.
Definition: BinaryLabels.h:37
class MulticlassStrategy used to construct generic multiclass classifiers with ensembles of binary cl...
virtual bool train_has_more()=0
virtual SGVector< int32_t > train_prepare_next()
virtual SGVector< index_t > decide_label_multiple_output(SGVector< float64_t > outputs, int32_t n_outputs)
virtual void train_start(CMulticlassLabels *orig_labels, CBinaryLabels *train_labels)
virtual int32_t decide_label(SGVector< float64_t > outputs)=0
EProbHeuristicType get_prob_heuris_type()

SHOGUN Machine Learning Toolbox - Documentation