SHOGUN  3.2.1
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
VwConditionalProbabilityTree.h
浏览该文件的文档.
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 
36 
38 class CVwConditionalProbabilityTree: public CTreeMachine<VwConditionalProbabilityTreeNodeData>
39 {
40 public:
41 
43  CVwConditionalProbabilityTree(int32_t num_passes=1)
44  :m_num_passes(num_passes), m_feats(NULL)
45  {
46  }
47 
50 
52  virtual const char* get_name() const { return "VwConditionalProbabilityTree"; }
53 
55  void set_num_passes(int32_t num_passes)
56  {
57  m_num_passes = num_passes;
58  }
59 
61  int32_t get_num_passes() const
62  {
63  return m_num_passes;
64  }
65 
70  {
71  SG_REF(feats);
73  m_feats = feats;
74  }
75 
77  virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL);
78 
80  virtual int32_t apply_multiclass_example(VwExample* ex);
81 protected:
83  virtual bool train_require_labels() const { return false; }
84 
91  virtual bool train_machine(CFeatures* data);
92 
96  void train_example(VwExample *ex);
97 
102  void train_path(VwExample *ex, bnode_t *node);
103 
110 
114  int32_t create_machine(VwExample *ex);
115 
121  virtual bool which_subtree(bnode_t *node, VwExample *ex)=0;
122 
125 
130 
131  int32_t m_num_passes;
132  std::map<int32_t, bnode_t*> m_leaves;
134 };
135 
136 } /* shogun */
137 
138 #endif /* end of include guard: CONDITIONALPROBABILITYTREE_H__ */
139 

SHOGUN 机器学习工具包 - 项目文档