|
CNum 0.2.1
CPU-optimized ML library for C++
|
A decision tree used in various gradient-boosting models as a weak learner. More...
#include <TreeBooster.h>
Public Member Functions | |
| TreeBooster (arena_t *a=nullptr, int md=5, int ms=3, double weight_decay=0.0, double reg_lambda=1.0, double gamma=0.0) | |
| Overloaded default constructor. | |
| TreeBooster (const TreeBooster &other) noexcept | |
| Copy constructor. | |
| TreeBooster & | operator= (const TreeBooster &other) noexcept |
| Copy equals operator. | |
| TreeBooster (TreeBooster &&other) noexcept | |
| Move constructor. | |
| TreeBooster & | operator= (TreeBooster &&other) noexcept |
| Move equals operator. | |
| virtual | ~TreeBooster () |
| Destructor. | |
| void | set_root (TreeBoosterNode *root) |
| Set the root of the tree. | |
| virtual void | fit (DataMatrix &X, std::shared_ptr< CNum::Data::Shelf[]> shelves, double *g, double *h, DataPartition &partition)=0 |
| CNum::DataStructs::Matrix< double > | predict (CNum::DataStructs::Matrix< double > &data) |
| Inference (making predictions) on tabular data. | |
| arena_view_t | init_hist_view (size_t n_data_cols) |
| Allocate space for histograms on the arena. | |
| std::string | to_json () |
| Save tree data in json encoded string. | |
Static Public Member Functions | |
| static size_t | partition_data (const CNum::DataStructs::Matrix< int > &X, double *g, double *h, size_t feat, uint8_t bin, const DataPartition &partition) |
| Partition idx array, g, and h based on a split to make each nodes' slice of the dataset contigous. | |
| static void | histogram_subtraction (const arena_view_t &parent_hist_view, arena_view_t &small_hist_view, arena_view_t &large_hist_view) |
| Subtract a parent histogram from "small" histogram for histogram caching. | |
Protected Attributes | |
| TreeBoosterNode * | _root |
| int | _max_depth |
| int | _min_samples |
| double | _reg_lambda |
| double | _gamma |
| double | _weight_decay |
| arena_t * | _arena |
A decision tree used in various gradient-boosting models as a weak learner.
The TreeBooster class is a robust and effecient weak learner that is good at recognizing subtle relationships between features in tabular data. While weak on their own when used in gradient-boosting algorithms become extremely powerful.
| CNum::Model::Tree::TreeBooster::TreeBooster | ( | arena_t * | a = nullptr, |
| int | md = 5, | ||
| int | ms = 3, | ||
| double | weight_decay = 0.0, | ||
| double | reg_lambda = 1.0, | ||
| double | gamma = 0.0 ) |
Overloaded default constructor.
| a | The arena to use for allocation in this tree (arena of the parent thread in the tree building process) |
|
noexcept |
Copy constructor.
|
noexcept |
Move constructor.
|
virtual |
Destructor.
|
pure virtual |
Implemented in CNum::Model::Tree::XGTreeBooster.
|
static |
Subtract a parent histogram from "small" histogram for histogram caching.
CNum's tree boosting models exploit histogram caching which reduces the amount of histograms built by building the histogram for the smaller of 2 child node partitions and subtracting it from the parent to yield the larger partition's histogram
| parent_hist_view | The arena_view_t with the parent histogram |
| small_hist_view | The arena_view_t with the small partition's histogram |
| large_hist_view | The arena_view_t that we will fill with the difference of the parent and small histograms |
| arena_view_t CNum::Model::Tree::TreeBooster::init_hist_view | ( | size_t | n_data_cols | ) |
Allocate space for histograms on the arena.
| n_data_cols | The number of features in the dataset |
|
noexcept |
Copy equals operator.
|
noexcept |
Move equals operator.
|
static |
Partition idx array, g, and h based on a split to make each nodes' slice of the dataset contigous.
| X | The dataset (row-wise features) |
| g | The gradient array |
| h | The hessian array |
| feat | The feature associated with the split |
| bin | The bin associated with the split |
| partition | The current node's data partition |
| CNum::DataStructs::Matrix< double > CNum::Model::Tree::TreeBooster::predict | ( | CNum::DataStructs::Matrix< double > & | data | ) |
Inference (making predictions) on tabular data.
| data | The data to make predictions on |
| void CNum::Model::Tree::TreeBooster::set_root | ( | TreeBoosterNode * | root | ) |
Set the root of the tree.
| std::string CNum::Model::Tree::TreeBooster::to_json | ( | ) |
Save tree data in json encoded string.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |