CNum 0.2.1
CPU-optimized ML library for C++
Loading...
Searching...
No Matches
TreeBoosterNode.h
Go to the documentation of this file.
1#ifndef TREE_BOOSTER_NODE_H
2#define TREE_BOOSTER_NODE_H
3
5#include "CNum/Data/Data.h"
7
8#include <vector>
9#include <future>
10#include <cstring>
11
12namespace CNum::Model::Tree {
13 struct Split;
14 struct DataPartition;
15
16 // -------------
17 // Tree Node
18 // -------------
19
26 private:
38 static double get_gain(double gs,
39 double hs,
40 double gl,
41 double hl,
42 double gr,
43 double hr,
44 double reg_lambda = 1.0,
45 double gamma = 0);
46
50 static Split split_comparison(std::vector< std::future<Split> > &splits);
51
52 public:
54 double _value;
57
62 TreeBoosterNode *right = nullptr);
63
65
81 std::shared_ptr<CNum::Data::Shelf[]> shelves,
82 const double *g,
83 const double *h,
84 bool histogram_cache,
85 const arena_view_t &hist_view,
86 DataPartition &partition,
87 double weight_decay = 0.0,
88 double reg_lambda = 1.0,
89 double gamma = 0);
90
104 const double *g,
105 const double *h,
106 double weight_decay = 0.0,
107 double reg_lambda = 1.0,
108 double gamma = 0);
109
112 std::string to_json_string();
113
114 friend class TreeBooster;
115 };
116};
117
118#endif
struct arena_view arena_view_t
2d array abstraction
Definition Matrix.h:43
TreeBoosterNode * _right
Definition TreeBoosterNode.h:56
static Split find_best_split_greedy(CNum::DataStructs::Matrix< double > &X, const double *g, const double *h, double weight_decay=0.0, double reg_lambda=1.0, double gamma=0)
Find the best split at a tree node with the exact greedy method proposed in Chen & Guestrin's XGBoost...
Split _split
Definition TreeBoosterNode.h:53
static Split find_best_split_hist(const CNum::DataStructs::Matrix< int > &X, std::shared_ptr< CNum::Data::Shelf[]> shelves, const double *g, const double *h, bool histogram_cache, const arena_view_t &hist_view, DataPartition &partition, double weight_decay=0.0, double reg_lambda=1.0, double gamma=0)
Find the best split at a tree node with the histogram method (maximizing gain).
TreeBoosterNode(TreeBoosterNode *left=nullptr, TreeBoosterNode *right=nullptr)
Overloaded default constructor.
std::string to_json_string()
Save TreeBoosterNode data for an entire TreeBooster in a JSON formatted string.
double _value
Definition TreeBoosterNode.h:54
TreeBoosterNode * _left
Definition TreeBoosterNode.h:55
friend class TreeBooster
Definition TreeBoosterNode.h:114
Tree-based models.
Definition GBModel.h:11
Contains bins and the ranges of values they represent.
Definition Data.h:31
A data partition for the set of samples a tree node has to work with during the tree building process...
Definition TreeDefs.h:39
Holds data associated with the decision making process in a TreeBoosterNode.
Definition TreeDefs.h:50