SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
19 
20 namespace shogun
21 {
22 
31 class CConditionalProbabilityTree: public CTreeMachine<ConditionalProbabilityTreeNodeData>
32 {
33 public:
35  CConditionalProbabilityTree(int32_t num_passes=1)
36  :m_num_passes(num_passes), m_feats(NULL)
37  {
38  }
39 
42 
44  virtual const char* get_name() const { return "ConditionalProbabilityTree"; }
45 
47  void set_num_passes(int32_t num_passes)
48  {
49  m_num_passes = num_passes;
50  }
51 
53  int32_t get_num_passes() const
54  {
55  return m_num_passes;
56  }
57 
62  {
63  SG_REF(feats);
65  m_feats = feats;
66  }
67 
69  virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL);
70 
75 
77  void print_tree();
78 protected:
80  virtual bool train_require_labels() const { return false; }
81 
88  virtual bool train_machine(CFeatures* data);
89 
94  void train_example(SGVector<float32_t> ex, int32_t label);
95 
101 
108 
114 
119 
125  virtual bool which_subtree(bnode_t *node, SGVector<float32_t> ex)=0;
126 
129 
134 
135  int32_t m_num_passes;
136  std::map<int32_t, bnode_t*> m_leaves;
138 };
139 
140 } /* shogun */
141 
142 #endif /* end of include guard: CONDITIONALPROBABILITYTREE_H__ */
143 
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)
#define SG_UNREF(x)
Definition: SGRefObject.h:35
virtual CMulticlassLabels * apply_multiclass(CFeatures *data=NULL)
virtual bool which_subtree(bnode_t *node, SGVector< float32_t > ex)=0
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:48
#define SG_REF(x)
Definition: SGRefObject.h:34
void train_path(SGVector< float32_t > ex, bnode_t *node)
void train_node(SGVector< float32_t > ex, float64_t label, bnode_t *node)
The class Features is the base class of all feature objects.
Definition: Features.h:62
class TreeMachine, a base class for tree based multiclass classifiers. This class is derived from CBa...
Definition: TreeMachine.h:46
void compute_conditional_probabilities(SGVector< float32_t > ex)
virtual int32_t apply_multiclass_example(SGVector< float32_t > ex)

SHOGUN Machine Learning Toolbox - Documentation