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< tree > | CornerLeaf (uint64_t n) |
static shared_ptr< tree > | NonCornerLeaf (uint64_t n) |
Public Attributes | |
const shared_ptr< tree > | brighter |
const shared_ptr< tree > | darker |
const shared_ptr< tree > | similar |
const IsCorner | is_a_corner |
const int | feature_to_test |
const uint64_t | num_datapoints |
Private Member Functions | |
tree (IsCorner c, uint64_t n) |
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.
Definition at line 392 of file learn_fast_tree.cc.
00393 { 00394 Corner, 00395 NonCorner, 00396 NonTerminal 00397 };
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.
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().
00444 :brighter(b), darker(d), similar(s), is_a_corner(NonTerminal), feature_to_test(n), num_datapoints(num) 00445 {}
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.
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 {}
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.
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.
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().
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.
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().
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().