CNum 0.2.1
CPU-optimized ML library for C++
Loading...
Searching...
No Matches
CNum::Model::Tree::XGTreeBooster Class Reference

A tree booster modeled after Chen & Guestrin's XGBoost tree booster. More...

#include <XGTreeBooster.h>

Inheritance diagram for CNum::Model::Tree::XGTreeBooster:
CNum::Model::Tree::TreeBooster

Public Member Functions

 XGTreeBooster (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 constructor.
 ~XGTreeBooster ()
 Destructor.
virtual void fit (DataMatrix &X, std::shared_ptr< CNum::Data::Shelf[]> shelves, double *g, double *h, DataPartition &partition) override
 Unified fit function.
Public Member Functions inherited from 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.
 TreeBooster (const TreeBooster &other) noexcept
 Copy constructor.
TreeBoosteroperator= (const TreeBooster &other) noexcept
 Copy equals operator.
 TreeBooster (TreeBooster &&other) noexcept
 Move constructor.
TreeBoosteroperator= (TreeBooster &&other) noexcept
 Move equals operator.
virtual ~TreeBooster ()
 Destructor.
void set_root (TreeBoosterNode *root)
 Set the root of the tree.
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.

Additional Inherited Members

Static Public Member Functions inherited from CNum::Model::Tree::TreeBooster
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 inherited from CNum::Model::Tree::TreeBooster
TreeBoosterNode_root
int _max_depth
int _min_samples
double _reg_lambda
double _gamma
double _weight_decay
arena_t_arena

Detailed Description

A tree booster modeled after Chen & Guestrin's XGBoost tree booster.

Constructor & Destructor Documentation

◆ XGTreeBooster()

CNum::Model::Tree::XGTreeBooster::XGTreeBooster ( 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 constructor.

Parameters
mdThe max depth of the tree
msThe min samples needed to continue with the tree building process
reg_lambdaReg Lambda; A regularization parameter
gammaGamma; A regularization parameter

◆ ~XGTreeBooster()

CNum::Model::Tree::XGTreeBooster::~XGTreeBooster ( )

Destructor.

Member Function Documentation

◆ fit()

virtual void CNum::Model::Tree::XGTreeBooster::fit ( DataMatrix & X,
std::shared_ptr< CNum::Data::Shelf[]> shelves,
double * g,
double * h,
DataPartition & partition )
overridevirtual

Unified fit function.

Parameters
XThe dataset
shelvesThe bins and values associated with their boundaries
gThe gradient array
hThe hessian array
partitionThe partition of the node's slice of the dataset

Implements CNum::Model::Tree::TreeBooster.


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