SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VwConditionalProbabilityTree.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 
20 
21 namespace shogun
22 {
23 
26 {
28  int32_t label;
31 
34 };
35 
38 
40 class CVwConditionalProbabilityTree: public CTreeMachine<VwConditionalProbabilityTreeNodeData>
41 {
42 public:
43 
45  CVwConditionalProbabilityTree(int32_t num_passes=1)
46  :m_num_passes(num_passes), m_feats(NULL)
47  {
48  }
49 
52 
54  virtual const char* get_name() const { return "VwConditionalProbabilityTree"; }
55 
57  void set_num_passes(int32_t num_passes)
58  {
59  m_num_passes = num_passes;
60  }
61 
63  int32_t get_num_passes() const
64  {
65  return m_num_passes;
66  }
67 
72  {
73  SG_REF(feats);
75  m_feats = feats;
76  }
77 
79  virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL);
80 
82  virtual int32_t apply_multiclass_example(VwExample* ex);
83 protected:
85  virtual bool train_require_labels() const { return false; }
86 
93  virtual bool train_machine(CFeatures* data);
94 
98  void train_example(VwExample *ex);
99 
104  void train_path(VwExample *ex, bnode_t *node);
105 
112 
116  int32_t create_machine(VwExample *ex);
117 
123  virtual bool which_subtree(bnode_t *node, VwExample *ex)=0;
124 
127 
132 
133  int32_t m_num_passes;
134  std::map<int32_t, bnode_t*> m_leaves;
136 };
137 
138 } /* shogun */
139 
140 #endif /* end of include guard: CONDITIONALPROBABILITYTREE_H__ */
141 

SHOGUN Machine Learning Toolbox - Documentation