GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
GRT::Node Class Reference
Inheritance diagram for GRT::Node:
GRT::GRTBase GRT::ClusterTreeNode GRT::DecisionTreeNode GRT::RegisterNode< T > GRT::RegressionTreeNode GRT::RegisterNode< GRT::ClusterTreeNode > GRT::RegisterNode< GRT::DecisionTreeClusterNode > GRT::RegisterNode< GRT::DecisionTreeNode > GRT::RegisterNode< GRT::DecisionTreeThresholdNode > GRT::RegisterNode< GRT::DecisionTreeTripleFeatureNode > GRT::RegisterNode< GRT::RegressionTreeNode >

Public Types

typedef std::map< string, Node *(*)() > StringNodeMap
 

Public Member Functions

 Node ()
 
virtual ~Node ()
 
virtual bool predict (const VectorDouble &x)
 
virtual bool predict (const VectorDouble &x, VectorDouble &y)
 
virtual bool clear ()
 
virtual bool print () const
 
virtual bool getModel (ostream &stream) const
 
virtual bool saveToFile (fstream &file) const
 
virtual bool loadFromFile (fstream &file)
 
virtual NodedeepCopyNode () const
 
string getNodeType () const
 
UINT getDepth () const
 
UINT getNodeID () const
 
UINT getPredictedNodeID () const
 
UINT getMaxDepth () const
 
bool getIsLeafNode () const
 
bool getHasParent () const
 
bool getHasLeftChild () const
 
bool getHasRightChild () const
 
NodegetParent () const
 
NodegetLeftChild () const
 
NodegetRightChild () const
 
bool initNode (Node *parent, const UINT depth, const UINT nodeID, const bool isLeafNode=false)
 
bool setParent (Node *parent)
 
bool setLeftChild (Node *leftChild)
 
bool setRightChild (Node *rightChild)
 
bool setDepth (const UINT depth)
 
bool setNodeID (const UINT nodeID)
 
bool setIsLeafNode (const bool isLeafNode)
 
NodecreateNewInstance () const
 
- Public Member Functions inherited from GRT::GRTBase
 GRTBase (void)
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
string getClassType () const
 
string getLastWarningMessage () const
 
string getLastErrorMessage () const
 
string getLastInfoMessage () const
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () const
 

Static Public Member Functions

static NodecreateInstanceFromString (string const &nodeType)
 
- Static Public Member Functions inherited from GRT::GRTBase
static string getGRTVersion (bool returnRevision=true)
 
static string getGRTRevison ()
 

Protected Member Functions

virtual bool saveParametersToFile (fstream &file) const
 
virtual bool loadParametersFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::GRTBase
double SQR (const double &x) const
 

Static Protected Member Functions

static StringNodeMapgetMap ()
 

Protected Attributes

string nodeType
 
UINT depth
 
UINT nodeID
 
UINT predictedNodeID
 
bool isLeafNode
 
Nodeparent
 
NodeleftChild
 
NoderightChild
 
- Protected Attributes inherited from GRT::GRTBase
string classType
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
TrainingLog trainingLog
 
TestingLog testingLog
 
WarningLog warningLog
 

Detailed Description

Definition at line 37 of file Node.h.

Member Typedef Documentation

typedef std::map< string, Node*(*)() > GRT::Node::StringNodeMap

Defines a map between a string (which will contain the name of the node, such as DecisionTreeNode) and a function returns a new instance of that node.

Definition at line 197 of file Node.h.

Constructor & Destructor Documentation

GRT::Node::Node ( )

Default Constructor. Sets all the pointers to NULL.

Definition at line 42 of file Node.cpp.

GRT::Node::~Node ( )
virtual

Default Destructor. Cleans up any memory.

Definition at line 55 of file Node.cpp.

Member Function Documentation

bool GRT::Node::clear ( )
virtual

This functions cleans up any dynamic memory assigned by the node. It will recursively clear the memory for the left and right child nodes.

Returns
returns true of the node was cleared correctly, false otherwise

Reimplemented in GRT::ClusterTreeNode, GRT::RegressionTreeNode, GRT::DecisionTreeNode, GRT::DecisionTreeClusterNode, GRT::DecisionTreeThresholdNode, and GRT::DecisionTreeTripleFeatureNode.

Definition at line 69 of file Node.cpp.

Node * GRT::Node::createInstanceFromString ( string const &  nodeType)
static

Creates a new classifier instance based on the input string (which should contain the name of a valid classifier such as ANBC).

Parameters
stringconst &classifierType: the name of the classifier
Returns
Classifier*: a pointer to the new instance of the classifier

Definition at line 28 of file Node.cpp.

Node * GRT::Node::createNewInstance ( ) const

Creates a new classifier instance based on the current classifierType string value.

Returns
Classifier*: a pointer to the new instance of the classifier

Definition at line 38 of file Node.cpp.

Node * GRT::Node::deepCopyNode ( ) const
virtual

This function returns a deep copy of the Node and all it's children. The user is responsible for managing the dynamic data that is returned from this function as a pointer.

Returns
returns a pointer to a deep copy of the Node, or NULL if the deep copy was not successful

Reimplemented in GRT::RegressionTreeNode, GRT::ClusterTreeNode, GRT::DecisionTreeNode, GRT::DecisionTreeClusterNode, GRT::DecisionTreeThresholdNode, and GRT::DecisionTreeTripleFeatureNode.

Definition at line 267 of file Node.cpp.

UINT GRT::Node::getDepth ( ) const

This function returns the depth of the node. The depth is the level in the tree at which the node is located, the root node has a depth of 0.

Returns
returns the depth of the node in the tree

Definition at line 299 of file Node.cpp.

bool GRT::Node::getHasLeftChild ( ) const

This function returns true if this node has a leftChild, false otherwise.

Returns
returns true if this node has a leftChild, false otherwise

Definition at line 342 of file Node.cpp.

bool GRT::Node::getHasParent ( ) const

This function returns true if this node has a parent, false otherwise.

Returns
returns true if this node has a parent, false otherwise

Definition at line 338 of file Node.cpp.

bool GRT::Node::getHasRightChild ( ) const

This function returns true if this node has a rightChild, false otherwise.

Returns
returns true if this node has a rightChild, false otherwise

Definition at line 346 of file Node.cpp.

bool GRT::Node::getIsLeafNode ( ) const

This function returns true if this node is a leaf node, false otherwise.

Returns
returns true if this node is a leaf node, false otherwise

Definition at line 334 of file Node.cpp.

bool GRT::Node::getModel ( ostream &  stream) const
virtual

This function adds the current model to the formatted stream. This function should be overwritten by the derived class.

Parameters
ostream&file: a reference to the stream the model will be added to
Returns
returns true if the model was added successfully, false otherwise

Reimplemented in GRT::DecisionTreeNode, GRT::DecisionTreeClusterNode, GRT::DecisionTreeThresholdNode, and GRT::DecisionTreeTripleFeatureNode.

Definition at line 111 of file Node.cpp.

UINT GRT::Node::getNodeID ( ) const

This function returns the nodeID, this is a unique ID that represents this node within a Tree.

Returns
returns the nodeID of this node

Definition at line 303 of file Node.cpp.

string GRT::Node::getNodeType ( ) const

This function returns the node type, this is the type of node defined by the class that inherits from the Node base class.

Returns
returns the nodeType

Definition at line 295 of file Node.cpp.

UINT GRT::Node::getPredictedNodeID ( ) const

This function returns the predictedNodeID, this is ID of the leaf node that was reached during the last prediction call

Returns
returns the predictedNodeID

Definition at line 307 of file Node.cpp.

bool GRT::Node::loadFromFile ( fstream &  file)
virtual

This loads the Node from a file.

Parameters
fstream&file: a reference to the file the Node model will be loaded from
Returns
returns true if the model was loaded successfully, false otherwise

Definition at line 173 of file Node.cpp.

virtual bool GRT::Node::loadParametersFromFile ( fstream &  file)
inlineprotectedvirtual

This loads the custom parameters to from file. This can be used by any class that inherits from the Node class to load the custom parameters from that class from a file by overridding this function.

Parameters
fstream&file: a reference to the file the parameters will be loaded from
Returns
returns true if the parameters were loaded successfully, false otherwise

Reimplemented in GRT::ClusterTreeNode, GRT::RegressionTreeNode, GRT::DecisionTreeNode, GRT::DecisionTreeTripleFeatureNode, GRT::DecisionTreeClusterNode, and GRT::DecisionTreeThresholdNode.

Definition at line 235 of file Node.h.

bool GRT::Node::predict ( const VectorDouble &  x)
virtual

This function predicts if the input is greater than or equal to the nodes threshold. This function should be overwritten by the inheriting class.

Parameters
constVectorDouble &x: the input vector that will be used for the prediction
Returns
returns true if the input is greater than or equal to the nodes threshold, false otherwise

Reimplemented in GRT::RegressionTreeNode, GRT::ClusterTreeNode, GRT::DecisionTreeClusterNode, GRT::DecisionTreeThresholdNode, and GRT::DecisionTreeTripleFeatureNode.

Definition at line 59 of file Node.cpp.

bool GRT::Node::predict ( const VectorDouble &  x,
VectorDouble &  y 
)
virtual

This function recursively predicts if the probability of the input vector. This function should be overwritten by the inheriting class.

Parameters
constVectorDouble &x: the input vector that will be used for the prediction
VectorDouble&y: a reference to a vector that will store the results
Returns
returns true if the input is greater than or equal to the nodes threshold, false otherwise

Reimplemented in GRT::RegressionTreeNode, GRT::ClusterTreeNode, and GRT::DecisionTreeNode.

Definition at line 64 of file Node.cpp.

bool GRT::Node::print ( ) const
virtual

This functions prints the node data to std::out. It will recursively print all the child nodes.

Returns
returns true if the data was printed correctly, false otherwise

Reimplemented in GRT::ClusterTreeNode, GRT::RegressionTreeNode, GRT::DecisionTreeClusterNode, GRT::DecisionTreeThresholdNode, and GRT::DecisionTreeTripleFeatureNode.

Definition at line 100 of file Node.cpp.

virtual bool GRT::Node::saveParametersToFile ( fstream &  file) const
inlineprotectedvirtual

This saves the custom parameters to a file. This can be used by any class that inherits from the Node class to save the custom parameters from that class to a file by overridding this function.

Parameters
fstream&file: a reference to the file the parameters will be saved to
Returns
returns true if the parameters were saved successfully, false otherwise

Reimplemented in GRT::ClusterTreeNode, GRT::RegressionTreeNode, GRT::DecisionTreeNode, GRT::DecisionTreeTripleFeatureNode, GRT::DecisionTreeClusterNode, and GRT::DecisionTreeThresholdNode.

Definition at line 223 of file Node.h.

bool GRT::Node::saveToFile ( fstream &  file) const
virtual

This saves the Node to a file.

Parameters
fstream&file: a reference to the file the Node model will be saved to
Returns
returns true if the model was saved successfully, false otherwise

Definition at line 131 of file Node.cpp.


The documentation for this class was generated from the following files: