SHOGUN  v3.0.0
 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 
18 
19 namespace shogun
20 {
21 
24 {
26  int32_t label;
29 
32 };
33 
35 class CVwConditionalProbabilityTree: public CTreeMachine<VwConditionalProbabilityTreeNodeData>
36 {
37 public:
39 
41  CVwConditionalProbabilityTree(int32_t num_passes=1)
42  :m_num_passes(num_passes), m_feats(NULL)
43  {
44  }
45 
48 
50  virtual const char* get_name() const { return "VwConditionalProbabilityTree"; }
51 
53  void set_num_passes(int32_t num_passes)
54  {
55  m_num_passes = num_passes;
56  }
57 
59  int32_t get_num_passes() const
60  {
61  return m_num_passes;
62  }
63 
68  {
69  SG_REF(feats);
71  m_feats = feats;
72  }
73 
75  virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL);
76 
78  virtual int32_t apply_multiclass_example(VwExample* ex);
79 protected:
81  virtual bool train_require_labels() const { return false; }
82 
89  virtual bool train_machine(CFeatures* data);
90 
94  void train_example(VwExample *ex);
95 
100  void train_path(VwExample *ex, node_t *node);
101 
108 
112  int32_t create_machine(VwExample *ex);
113 
119  virtual bool which_subtree(node_t *node, VwExample *ex)=0;
120 
123 
128 
129  int32_t m_num_passes;
130  std::map<int32_t, node_t*> m_leaves;
132 };
133 
134 } /* shogun */
135 
136 #endif /* end of include guard: CONDITIONALPROBABILITYTREE_H__ */
137 

SHOGUN Machine Learning Toolbox - Documentation