SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 
33  VwConditionalProbabilityTreeNodeData():label(-1), p_right(0) {}
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 
111  float64_t train_node(VwExample *ex, bnode_t *node);
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 
The node of the tree structure forming a TreeMachine The node contains pointer to its parent and poin...
float64_t train_node(VwExample *ex, bnode_t *node)
int32_t m_num_passes
number of passes for online training
#define SG_REF(x)
Definition: SGObject.h:54
Multiclass Labels for multi-class classification.
double float64_t
Definition: common.h:50
virtual CMulticlassLabels * apply_multiclass(CFeatures *data=NULL)
void set_features(CStreamingVwFeatures *feats)
Example class for VW.
Definition: vw_example.h:58
This class implements streaming features for use with VW.
void train_path(VwExample *ex, bnode_t *node)
CBinaryTreeMachineNode< VwConditionalProbabilityTreeNodeData > bnode_t
#define SG_UNREF(x)
Definition: SGObject.h:55
virtual bool which_subtree(bnode_t *node, VwExample *ex)=0
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual int32_t apply_multiclass_example(VwExample *ex)
CStreamingVwFeatures * m_feats
online features
class TreeMachine, a base class for tree based multiclass classifiers. This class is derived from CBa...
Definition: TreeMachine.h:48
std::map< int32_t, bnode_t * > m_leaves
class => leaf mapping

SHOGUN Machine Learning Toolbox - Documentation