SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
float64_t accumulate_conditional_probability(bnode_t *leaf)
The node of the tree structure forming a TreeMachine The node contains pointer to its parent and poin...
void train_example(SGVector< float32_t > ex, int32_t label)
void set_features(CStreamingDenseFeatures< float32_t > *feats)
virtual CMulticlassLabels * apply_multiclass(CFeatures *data=NULL)
virtual bool which_subtree(bnode_t *node, SGVector< float32_t > ex)=0
#define SG_REF(x)
Definition: SGObject.h:51
float64_t predict_node(SGVector< float32_t > ex, bnode_t *node)
Multiclass Labels for multi-class classification.
CStreamingDenseFeatures< float32_t > * m_feats
online features
int32_t m_num_passes
number of passes for online training
int32_t create_machine(SGVector< float32_t > ex)
std::map< int32_t, bnode_t * > m_leaves
class => leaf mapping
double float64_t
Definition: common.h:50
void train_path(SGVector< float32_t > ex, bnode_t *node)
void train_node(SGVector< float32_t > ex, float64_t label, bnode_t *node)
#define SG_UNREF(x)
Definition: SGObject.h:52
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
class TreeMachine, a base class for tree based multiclass classifiers. This class is derived from CBa...
Definition: TreeMachine.h:48
void compute_conditional_probabilities(SGVector< float32_t > ex)
virtual int32_t apply_multiclass_example(SGVector< float32_t > ex)

SHOGUN Machine Learning Toolbox - Documentation