SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConditionalProbabilityTree.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  * Copyright (C) 2012 Chiyuan Zhang
9  */
10 
11 #ifndef CONDITIONALPROBABILITYTREE_H__
12 #define CONDITIONALPROBABILITYTREE_H__
13 
14 #include <map>
15 
16 #include <shogun/lib/config.h>
17 
21 
22 namespace shogun
23 {
24 
33 class CConditionalProbabilityTree: public CTreeMachine<ConditionalProbabilityTreeNodeData>
34 {
35 public:
37  CConditionalProbabilityTree(int32_t num_passes=1)
38  :m_num_passes(num_passes), m_feats(NULL)
39  {
40  }
41 
44 
46  virtual const char* get_name() const { return "ConditionalProbabilityTree"; }
47 
49  void set_num_passes(int32_t num_passes)
50  {
51  m_num_passes = num_passes;
52  }
53 
55  int32_t get_num_passes() const
56  {
57  return m_num_passes;
58  }
59 
64  {
65  SG_REF(feats);
67  m_feats = feats;
68  }
69 
71  virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL);
72 
77 
79  void print_tree();
80 protected:
82  virtual bool train_require_labels() const { return false; }
83 
90  virtual bool train_machine(CFeatures* data);
91 
96  void train_example(SGVector<float32_t> ex, int32_t label);
97 
103 
110 
116 
121 
127  virtual bool which_subtree(bnode_t *node, SGVector<float32_t> ex)=0;
128 
131 
136 
137  int32_t m_num_passes;
138  std::map<int32_t, bnode_t*> m_leaves;
140 };
141 
142 } /* shogun */
143 
144 #endif /* end of include guard: CONDITIONALPROBABILITYTREE_H__ */
145 

SHOGUN Machine Learning Toolbox - Documentation