latest version v1.9 - last update 10 Apr 2010 |
a simple Node for decision trees More...
#include <ltiDecisionTree.h>
Public Member Functions | |
dtNode () | |
dtNode (const int &theId) | |
dtNode (const dtNode &other) | |
virtual | ~dtNode () |
const char * | getTypeName () const |
dtNode & | copy (const dtNode &other) |
dtNode & | operator= (const dtNode &other) |
virtual dtNode * | clone () const |
dtNode * | setLeftChild (dtNode *newLeft) |
dtNode * | setRightChild (dtNode *newRight) |
const dtNode * | getLeftChild () const |
const dtNode * | getRightChild () const |
bool | isLeaf () const |
void | setId (const int &theId) |
int | getId () const |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
virtual bool | read (ioHandler &handler, const bool complete=true) |
Protected Member Functions | |
int | assignIds () |
Protected Attributes | |
dtNode * | left |
dtNode * | right |
int | id |
a simple Node for decision trees
lti::decisionTree::dtNode::dtNode | ( | ) |
default constructor
lti::decisionTree::dtNode::dtNode | ( | const int & | theId | ) |
Constructor.
Sets the id of the node.
theId | the nodes id. |
lti::decisionTree::dtNode::dtNode | ( | const dtNode & | other | ) |
virtual lti::decisionTree::dtNode::~dtNode | ( | ) | [virtual] |
destructor
int lti::decisionTree::dtNode::assignIds | ( | ) | [protected] |
Assigns ids to the leaf node from left to right starting with 0.
The ids are equivalent to the positions in the decisionTrees outTemplate. The starting point is this node. Usually, this method will be called for the root node of some decisionTree. The method returns the number of leaf nodes.
virtual dtNode* lti::decisionTree::dtNode::clone | ( | ) | const [virtual] |
returns a pointer to a clone of the dtNode
Reimplemented in lti::crispDecisionTree::crispNode.
int lti::decisionTree::dtNode::getId | ( | ) | const |
Get the nodes id.
const dtNode* lti::decisionTree::dtNode::getLeftChild | ( | ) | const |
Gets the left child node.
const dtNode* lti::decisionTree::dtNode::getRightChild | ( | ) | const |
Gets the right child node.
const char* lti::decisionTree::dtNode::getTypeName | ( | ) | const [virtual] |
returns name of this type
Reimplemented from lti::object.
Reimplemented in lti::crispDecisionTree::crispNode.
bool lti::decisionTree::dtNode::isLeaf | ( | ) | const |
Returns true if this node is a leaf, ie it has no children.
virtual bool lti::decisionTree::dtNode::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
read the dtNode from the given ioHandler NOTE: Reading a node results in reading of the complete tree following this node.
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written. |
Reimplemented in lti::crispDecisionTree::crispNode.
void lti::decisionTree::dtNode::setId | ( | const int & | theId | ) |
Set the nodes id.
Sets the left child node and returns the previous left child node.
NOTE: No copy or clone is performed, ie left is the same pointer as newLeft. This is necessary for building trees.
newLeft | new left child node |
Sets the right child node and returns the previous right child node.
NOTE: No copy or clone is performed, ie left is the same pointer as newLeft. This is necessary for building trees.
newRight | new right child node |
virtual bool lti::decisionTree::dtNode::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
write the dtNode in the given ioHandler
NOTE: Writing a node results in writing of the complete tree following this node.
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written. |
Reimplemented in lti::crispDecisionTree::crispNode.
int lti::decisionTree::dtNode::id [protected] |
The nodes id.
It is used as a reference to the nodes position in the decisionTrees outTemplate. So the ids should always be between 0 and n-1 with n being the number of leaf nodes of the decision tree.
dtNode* lti::decisionTree::dtNode::left [protected] |
Pointer to the left child node.
dtNode* lti::decisionTree::dtNode::right [protected] |
Pointer to the right child node.