Represents a decision tree used for predictions.
More...
#include <DecisionTree.h>
|
|
| Tree () |
| | Default constructor.
|
| |
| | Tree (int id, std::string treePath) |
| | Constructor that initializes the tree from an xgboost model dump.
|
| |
| float | predictSingle (float *input, int curBase) |
| | Predicts the output for a single input.
|
| |
| void | predict (VectorPtr &input, std::vector< float > &resultVector, int numInputs, int numFeatures) |
| | Predicts the output for multiple inputs.
|
| |
| void | predictMissing (VectorPtr &input, std::vector< float > &resultVector, int numInputs, int numFeatures) |
| | Predicts the output for multiple inputs, handling missing values.
|
| |
|
| static void | constructTreeFromPath (std::string treePathIn, Node *tree) |
| | Constructs a tree from a file dumped from an xgboost model.
|
| |
| static void | constructTreeFromPathHelper (std::string treePathIn, std::vector< std::string > &relationships, std::vector< std::string > &innerNodes, std::vector< std::string > &leafNodes) |
| | Parses the file and categorizes the lines into relationships, inner nodes, and leaf nodes.
|
| |
| static void | processInnerNodes (std::vector< std::string > &innerNodes, Node *tree) |
| | Parses the lines corresponding to tree inner nodes.
|
| |
| static void | processLeafNodes (std::vector< std::string > &leafNodes, Node *tree) |
| | Parses the lines corresponding to tree leaf nodes.
|
| |
| static void | processRelationships (std::vector< std::string > &relationships, Node *tree) |
| | Parses the lines corresponding to tree relationships.
|
| |
|
|
Node | tree [MAX_NUM_NODES_PER_TREE] |
| | Array of tree nodes.
|
| |
|
int | treeId |
| | ID of the tree in the forest.
|
| |
Represents a decision tree used for predictions.
◆ Tree()
| ml::Tree::Tree |
( |
int | id, |
|
|
std::string | treePath ) |
|
inline |
Constructor that initializes the tree from an xgboost model dump.
- Parameters
-
| id | The ID of the tree. |
| treePath | Path to the file containing the tree structure. |
◆ constructTreeFromPath()
| static void ml::Tree::constructTreeFromPath |
( |
std::string | treePathIn, |
|
|
Node * | tree ) |
|
inlinestatic |
Constructs a tree from a file dumped from an xgboost model.
- Parameters
-
| treePathIn | Path to the file containing the tree structure. |
| tree | Pointer to the array of nodes to be populated. |
◆ constructTreeFromPathHelper()
| static void ml::Tree::constructTreeFromPathHelper |
( |
std::string | treePathIn, |
|
|
std::vector< std::string > & | relationships, |
|
|
std::vector< std::string > & | innerNodes, |
|
|
std::vector< std::string > & | leafNodes ) |
|
inlinestatic |
Parses the file and categorizes the lines into relationships, inner nodes, and leaf nodes.
- Parameters
-
| treePathIn | Path to the file containing the tree structure. |
| relationships | Vector to store relationship lines. |
| innerNodes | Vector to store inner node lines. |
| leafNodes | Vector to store leaf node lines. |
◆ predict()
| void ml::Tree::predict |
( |
VectorPtr & | input, |
|
|
std::vector< float > & | resultVector, |
|
|
int | numInputs, |
|
|
int | numFeatures ) |
|
inline |
Predicts the output for multiple inputs.
- Parameters
-
| input | Vector of input feature values. |
| resultVector | Vector to store the predicted values. |
| numInputs | Number of inputs. |
| numFeatures | Number of features per input. |
◆ predictMissing()
| void ml::Tree::predictMissing |
( |
VectorPtr & | input, |
|
|
std::vector< float > & | resultVector, |
|
|
int | numInputs, |
|
|
int | numFeatures ) |
|
inline |
Predicts the output for multiple inputs, handling missing values.
- Parameters
-
| input | Vector of input feature values. |
| resultVector | Vector to store the predicted values. |
| numInputs | Number of inputs. |
| numFeatures | Number of features per input. |
◆ predictSingle()
| float ml::Tree::predictSingle |
( |
float * | input, |
|
|
int | curBase ) |
|
inline |
Predicts the output for a single input.
- Parameters
-
| input | Pointer to the input feature values. |
| curBase | Base index for the current input. |
- Returns
- Predicted value.
◆ processInnerNodes()
| static void ml::Tree::processInnerNodes |
( |
std::vector< std::string > & | innerNodes, |
|
|
Node * | tree ) |
|
inlinestatic |
Parses the lines corresponding to tree inner nodes.
- Parameters
-
| innerNodes | Vector of strings representing inner nodes. |
| tree | Pointer to the array of nodes to be populated. |
◆ processLeafNodes()
| static void ml::Tree::processLeafNodes |
( |
std::vector< std::string > & | leafNodes, |
|
|
Node * | tree ) |
|
inlinestatic |
Parses the lines corresponding to tree leaf nodes.
- Parameters
-
| leafNodes | Vector of strings representing leaf nodes. |
| tree | Pointer to the array of nodes to be populated. |
◆ processRelationships()
| static void ml::Tree::processRelationships |
( |
std::vector< std::string > & | relationships, |
|
|
Node * | tree ) |
|
inlinestatic |
Parses the lines corresponding to tree relationships.
- Parameters
-
| relationships | Vector of strings representing relationships. |
| tree | Pointer to the array of nodes to be populated. |
The documentation for this class was generated from the following file: