tree Struct Reference

List of all members.


Detailed Description

This class represents a decision tree.

Each leaf node contains a class, being Corner or NonCorner. Each decision node contains a feature about which to make a ternary decision. Additionally, each node records how many datapoints were tested. The generated tree structure is not mutable.

Definition at line 387 of file learn_fast_tree.cc.


Public Types

enum  IsCorner { Corner, NonCorner, NonTerminal }

Public Member Functions

string stringify ()
 tree (shared_ptr< tree > b, shared_ptr< tree > d, shared_ptr< tree > s, int n, uint64_t num)

Static Public Member Functions

static shared_ptr< treeCornerLeaf (uint64_t n)
static shared_ptr< treeNonCornerLeaf (uint64_t n)

Public Attributes

const shared_ptr< treebrighter
const shared_ptr< treedarker
const shared_ptr< treesimilar
const IsCorner is_a_corner
const int feature_to_test
const uint64_t num_datapoints

Private Member Functions

 tree (IsCorner c, uint64_t n)

Member Enumeration Documentation

enum tree::IsCorner

The class of the leaf, and a sentinal to indacate that the node is not a leaf.

Now that I come back to this, it looks suspiciously like an instance of http://thedailywtf.com/Articles/What_Is_Truth_0x3f_.aspx Oh well.

Enumerator:
Corner 
NonCorner 
NonTerminal 

Definition at line 392 of file learn_fast_tree.cc.

00393     {
00394         Corner,
00395         NonCorner,
00396         NonTerminal
00397     };


Constructor & Destructor Documentation

tree::tree ( shared_ptr< tree b,
shared_ptr< tree d,
shared_ptr< tree s,
int  n,
uint64_t  num 
) [inline]

Create a non-leaf node.

Parameters:
b The brighter subtree
d The darker subtree
s The similar subtree
n Feature number to test
num Number of datapoints reaching this node.

Definition at line 443 of file learn_fast_tree.cc.

Referenced by CornerLeaf(), and NonCornerLeaf().

tree::tree ( IsCorner  c,
uint64_t  n 
) [inline, private]

The leaf node constructor is private to prevent a tree being constructed with invalid values.

see also CornerLeaf and NonCornerLeaf.

Parameters:
c Class of the node
n Number of datapoints which this node represents

Definition at line 453 of file learn_fast_tree.cc.

00454     :is_a_corner(c),feature_to_test(-1),num_datapoints(n)
00455     {}


Member Function Documentation

string tree::stringify (  )  [inline]

Convert the tree to a simple string representation.

This is allows comparison of two trees to see if they are the same. It's probably rather inefficient to hammer the string class compared to using an ostringstream, but this is not the slowest part of the program.

Returns:
a stringified tree representation

Definition at line 411 of file learn_fast_tree.cc.

References brighter, Corner, darker, is_a_corner, NonTerminal, and similar.

00412     {
00413         if(is_a_corner == NonTerminal)
00414             return "(" + brighter->stringify() + darker->stringify() + similar->stringify() + ")";
00415         else
00416             return string("(") + (is_a_corner == Corner?"1":"0")  +  ")";
00417     }

static shared_ptr<tree> tree::CornerLeaf ( uint64_t  n  )  [inline, static]

Create a leaf node which is a corner This special constructor function makes it impossible to construct a leaf with the NonTerminal class.

Parameters:
n number of datapoints reaching this node.

Definition at line 423 of file learn_fast_tree.cc.

References Corner, and tree().

Referenced by build_tree().

00424     {
00425         return shared_ptr<tree>(new tree(Corner, n));
00426     }

static shared_ptr<tree> tree::NonCornerLeaf ( uint64_t  n  )  [inline, static]

Creat a leaf node which is a non-corner This special constructor function makes it impossible to construct a leaf with the NonTerminal class.

Parameters:
n number of datapoints reaching this node.

Definition at line 432 of file learn_fast_tree.cc.

References NonCorner, and tree().

Referenced by build_tree().

00433     {
00434         return shared_ptr<tree>(new tree(NonCorner, n));
00435     }


Member Data Documentation

const shared_ptr<tree> tree::brighter

Subtrees.

Definition at line 399 of file learn_fast_tree.cc.

Referenced by print_tree(), and stringify().

const shared_ptr<tree> tree::darker

Subtrees.

Definition at line 400 of file learn_fast_tree.cc.

Referenced by print_tree(), and stringify().

const shared_ptr<tree> tree::similar

Subtrees.

Definition at line 401 of file learn_fast_tree.cc.

Referenced by print_tree(), and stringify().

const IsCorner tree::is_a_corner

Class of this node (if its a leaf).

Definition at line 402 of file learn_fast_tree.cc.

Referenced by print_tree(), and stringify().

const int tree::feature_to_test

Feature (ie pixel) to test if this is a non-leaf.

Definition at line 403 of file learn_fast_tree.cc.

Referenced by print_tree().

const uint64_t tree::num_datapoints

Number of datapoints passing through this node.

Definition at line 404 of file learn_fast_tree.cc.

Referenced by print_tree().


The documentation for this struct was generated from the following file:
Generated on Mon Mar 2 12:47:15 2009 for FAST-ER by  doxygen 1.5.3