ML functions
 
Loading...
Searching...
No Matches
Forest Class Reference

A class that represents a random forest model for prediction tasks. More...

#include <DecisionForest.h>

Public Member Functions

 Forest ()
 Default constructor.
 
 Forest (std::string pathToFolder, bool isClassification)
 Constructor that initializes the forest from a folder of tree files.
 
void constructForestFromFolder (std::string pathToFolder)
 Constructs the forest from a folder of tree files.
 
void constructForestFromPaths (std::vector< std::string > &treesPathIn)
 Constructs the forest from a list of tree file paths.
 
void predict (VectorPtr &input, std::vector< float > &resultVector, int numInputs, int numFeatures)
 Makes predictions using the forest.
 

Static Public Member Functions

static void vectorizeForestFolder (std::string pathToFolder, std::vector< std::string > &pathVector)
 Scans a folder and collects paths to tree files.
 

Public Attributes

Node forest [MAX_NUM_TREES][MAX_NUM_NODES_PER_TREE]
 Array of trees in the forest.
 
int numTrees
 Number of trees in the forest.
 
bool isClassification
 Flag indicating whether the forest is used for classification.
 

Detailed Description

A class that represents a random forest model for prediction tasks.

This class provides functionality to construct a random forest from a folder of tree files and make predictions using the forest.

Constructor & Destructor Documentation

◆ Forest()

Forest::Forest ( std::string pathToFolder,
bool isClassification )
inline

Constructor that initializes the forest from a folder of tree files.

Parameters
pathToFolderThe path to the folder containing tree files.
isClassificationFlag indicating whether the forest is used for classification.

Member Function Documentation

◆ constructForestFromFolder()

void Forest::constructForestFromFolder ( std::string pathToFolder)
inline

Constructs the forest from a folder of tree files.

Parameters
pathToFolderThe path to the folder containing tree files.

◆ constructForestFromPaths()

void Forest::constructForestFromPaths ( std::vector< std::string > & treesPathIn)
inline

Constructs the forest from a list of tree file paths.

Parameters
treesPathInA vector of paths to tree files.

◆ predict()

void Forest::predict ( VectorPtr & input,
std::vector< float > & resultVector,
int numInputs,
int numFeatures )
inline

Makes predictions using the forest.

Parameters
inputThe input vector containing feature values.
resultVectorA vector to store the prediction results.
numInputsThe number of input samples.
numFeaturesThe number of features in each input sample.

◆ vectorizeForestFolder()

static void Forest::vectorizeForestFolder ( std::string pathToFolder,
std::vector< std::string > & pathVector )
inlinestatic

Scans a folder and collects paths to tree files.

Parameters
pathToFolderThe path to the folder containing tree files.
pathVectorA vector to store the paths of tree files.

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