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

Public Types

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

Public Member Functions

 Node ()
 
virtual ~Node ()
 
virtual bool predict (const VectorFloat &x)
 
virtual bool predict (const VectorFloat &x, VectorFloat &y)
 
virtual bool computeFeatureWeights (VectorFloat &weights) const
 
virtual bool computeLeafNodeWeights (MatrixFloat &weights) const
 
virtual bool clear ()
 
virtual bool print () const
 
virtual bool getModel (std::ostream &stream) const
 
virtual bool saveToFile (std::fstream &file) const
 
virtual bool loadFromFile (std::fstream &file)
 
virtual NodedeepCopyNode () const
 
std::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 GRTBase
 GRTBase (void)
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
std::string getClassType () const
 
std::string getLastWarningMessage () const
 
std::string getLastErrorMessage () const
 
std::string getLastInfoMessage () const
 
bool setInfoLoggingEnabled (const bool loggingEnabled)
 
bool setWarningLoggingEnabled (const bool loggingEnabled)
 
bool setErrorLoggingEnabled (const bool loggingEnabled)
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () const
 

Static Public Member Functions

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

Protected Member Functions

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

Static Protected Member Functions

static StringNodeMapgetMap ()
 

Protected Attributes

std::string nodeType
 
UINT depth
 
UINT nodeID
 
UINT predictedNodeID
 
bool isLeafNode
 
Nodeparent
 
NodeleftChild
 
NoderightChild
 
- Protected Attributes inherited from GRTBase
std::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< std::string, Node*(*)() > 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 215 of file Node.h.

Constructor & Destructor Documentation

Node::Node ( )

Default Constructor. Sets all the pointers to NULL.

Definition at line 42 of file Node.cpp.

Node::~Node ( )
virtual

Default Destructor. Cleans up any memory.

Definition at line 55 of file Node.cpp.

Member Function Documentation

bool 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 ClusterTreeNode, RegressionTreeNode, DecisionTreeNode, DecisionTreeClusterNode, DecisionTreeThresholdNode, and DecisionTreeTripleFeatureNode.

Definition at line 69 of file Node.cpp.

bool Node::computeFeatureWeights ( VectorFloat weights) const
virtual

This function recursively computes the weights of features used for classification nodes and stores the results in the weights vector. This function should be overwritten by the inheriting class.

Parameters
weightsthe input vector that will be used to store the weights
Returns
returns true if the weights were updated, false otherwise

Reimplemented in DecisionTreeClusterNode.

Definition at line 100 of file Node.cpp.

bool Node::computeLeafNodeWeights ( MatrixFloat weights) const
virtual

This function recursively computes the weights of features used for classification nodes and stores the results in the weights vector. This function should be overwritten by the inheriting class.

Parameters
weightsthe input matrix that will be used to store the weights, rows represent classes, columns represent features
Returns
returns true if the weights were updated, false otherwise

Reimplemented in DecisionTreeClusterNode.

Definition at line 104 of file Node.cpp.

Node * Node::createInstanceFromString ( std::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 * 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 * 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 RegressionTreeNode, ClusterTreeNode, DecisionTreeClusterNode, DecisionTreeNode, DecisionTreeThresholdNode, and DecisionTreeTripleFeatureNode.

Definition at line 275 of file Node.cpp.

UINT 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 307 of file Node.cpp.

bool 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 350 of file Node.cpp.

bool 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 346 of file Node.cpp.

bool 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 354 of file Node.cpp.

bool 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 342 of file Node.cpp.

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

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

Parameters
filea reference to the stream the model will be added to
Returns
returns true if the model was added successfully, false otherwise

Reimplemented in DecisionTreeClusterNode, DecisionTreeNode, DecisionTreeThresholdNode, and DecisionTreeTripleFeatureNode.

Definition at line 119 of file Node.cpp.

UINT 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 311 of file Node.cpp.

std::string 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 303 of file Node.cpp.

UINT 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 315 of file Node.cpp.

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

This loads the Node from a file.

Parameters
filea 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 181 of file Node.cpp.

virtual bool Node::loadParametersFromFile ( std::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
filea reference to the file the parameters will be loaded from
Returns
returns true if the parameters were loaded successfully, false otherwise

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

Definition at line 250 of file Node.h.

bool Node::predict ( const VectorFloat 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
xthe 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 RegressionTreeNode, ClusterTreeNode, DecisionTreeClusterNode, DecisionTreeThresholdNode, and DecisionTreeTripleFeatureNode.

Definition at line 59 of file Node.cpp.

bool Node::predict ( const VectorFloat x,
VectorFloat y 
)
virtual

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

Parameters
xthe input vector that will be used for the prediction
ya 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 RegressionTreeNode, ClusterTreeNode, and DecisionTreeNode.

Definition at line 64 of file Node.cpp.

bool 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 ClusterTreeNode, RegressionTreeNode, DecisionTreeClusterNode, DecisionTreeThresholdNode, and DecisionTreeTripleFeatureNode.

Definition at line 108 of file Node.cpp.

virtual bool Node::saveParametersToFile ( std::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
filea reference to the file the parameters will be saved to
Returns
returns true if the parameters were saved successfully, false otherwise

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

Definition at line 241 of file Node.h.

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

This saves the Node to a file.

Parameters
filea 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 139 of file Node.cpp.


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