|
CNum 0.2.1
CPU-optimized ML library for C++
|
A gradient-boosting model for any child of the TreeBooster class. More...
#include <GBModel.h>
Public Member Functions | |
| GBModel (std::string lt="MSE", int n_learners=200, double lr=0.1, double ss=0.25, int md=5, int ms=3, SplitAlg sa=HIST, ::std::string activation_func="", double weight_decay=0.0, double rl=1.0, double gamma=0.0, SubsampleFunction ssf=default_subsample) | |
| Overloaded default constructor. | |
| GBModel (::CNum::Model::Loss::LossProfile loss_profile, int n_learners, double lr, double ss, int md, int ms, SplitAlg sa, ::CNum::Model::Activation::ActivationFunc activation_func, double weight_decay, double rl, double gamma, SubsampleFunction ssf=default_subsample) | |
| Parameterized constructor. | |
| GBModel (const GBModel &other) noexcept | |
| Copy constructor. | |
| GBModel< TreeType > & | operator= (const GBModel &other) noexcept |
| Copy assignment. | |
| GBModel (GBModel &&other) noexcept | |
| Move constructor. | |
| GBModel< TreeType > & | operator= (GBModel &&other) noexcept |
| Move assignment. | |
| ~GBModel () | |
| Destructor. | |
| void | fit (::CNum::DataStructs::Matrix< double > &X, ::CNum::DataStructs::Matrix< double > &y, bool verbose=true) |
| Train the model. | |
| ::CNum::DataStructs::Matrix< double > | predict (::CNum::DataStructs::Matrix< double > &data) |
| Inference (making predictions). | |
| void | save_model (std::string path) |
| Save Model to JSON encoded ".cmod" file. | |
Static Public Member Functions | |
| static GBModel< TreeType > | load_model (std::string path) |
| Load Model from JSON encoded ".cmod" file. | |
A gradient-boosting model for any child of the TreeBooster class.
| TreeType | A child of the TreeBooster class |
The GBModel is a robust gradient-boosting model that can be used for both regression and classification on tabular data; simply set the loss and activation parameters of the constructor accordingly (see Loss and Activation classes) for available Loss and Activation functions.
| CNum::Model::Tree::GBModel< TreeType >::GBModel | ( | std::string | lt = "MSE", |
| int | n_learners = 200, | ||
| double | lr = 0.1, | ||
| double | ss = 0.25, | ||
| int | md = 5, | ||
| int | ms = 3, | ||
| SplitAlg | sa = HIST, | ||
| ::std::string | activation_func = "", | ||
| double | weight_decay = 0.0, | ||
| double | rl = 1.0, | ||
| double | gamma = 0.0, | ||
| SubsampleFunction | ssf = default_subsample ) |
Overloaded default constructor.
| lt | Loss Type (the name of the loss function) |
| n_learners | The number of TreeBooster learners to use |
| lr | The learning rate |
| ss | The amount of the dataset to sample for each tree |
| md | The max depth of each tree |
| ms | The minimum number of samples required to continue building a tree |
| sa | Split Algorithm; The method used to find the best splits at each node (GREEDY or HIST) |
| activation_func | The name of the activation function to apply after making predictions |
| weight_decay | A threshold used to detirmine whether a split is worth considering |
| rl | Reg Lambda; A regularization parameter used in gain calculations |
| gamma | A regularization parameter used in gain calculations |
| ssf | The function used to take subsamples of the data that a TreeBooster is trained on |
In the tree building process a split is only taken if the sum of the hessians in the resultant data partitions are both greater than weight_decay.
See TreeBoosterNode to understand how the regularization parameters are used
| CNum::Model::Tree::GBModel< TreeType >::GBModel | ( | ::CNum::Model::Loss::LossProfile | loss_profile, |
| int | n_learners, | ||
| double | lr, | ||
| double | ss, | ||
| int | md, | ||
| int | ms, | ||
| SplitAlg | sa, | ||
| ::CNum::Model::Activation::ActivationFunc | activation_func, | ||
| double | weight_decay, | ||
| double | rl, | ||
| double | gamma, | ||
| SubsampleFunction | ssf = default_subsample ) |
Parameterized constructor.
| loss_profile | The LossProfile for the loss function |
| n_learners | The number of TreeBooster learners to use |
| lr | The learning rate |
| ss | The amount of the dataset to sample for each tree |
| md | The max depth of each tree |
| ms | The minimum number of samples required to continue building a tree |
| sa | Split Algorithm; The method used to find the best splits at each node (GREEDY or HIST) |
| activation_func | The activation function to apply after making predictions |
| weight_decay | A threshold used to detirmine whether a split is worth considering |
| rl | Reg Lambda; A regularization parameter used in gain calculations |
| gamma | A regularization parameter used in gain calculations |
| ssf | The function used to take subsamples of the data that a TreeBooster is trained on |
In the tree building process a split is only taken if the sum of the hessians in the resultant data partitions are both greater than weight_decay.
See TreeBoosterNode to understand how the regularization parameters are used
|
noexcept |
Copy constructor.
|
noexcept |
Move constructor.
| CNum::Model::Tree::GBModel< TreeType >::~GBModel | ( | ) |
Destructor.
| void CNum::Model::Tree::GBModel< TreeType >::fit | ( | ::CNum::DataStructs::Matrix< double > & | X, |
| ::CNum::DataStructs::Matrix< double > & | y, | ||
| bool | verbose = true ) |
Train the model.
| X | The tabular data used to train the GBModel |
| y | The labels for the data (the intended output of the model) |
|
static |
|
noexcept |
Copy assignment.
|
noexcept |
Move assignment.
| CNum::DataStructs::Matrix< double > CNum::Model::Tree::GBModel< TreeType >::predict | ( | ::CNum::DataStructs::Matrix< double > & | data | ) |
Inference (making predictions).
| The | data to make predictions on |
| void CNum::Model::Tree::GBModel< TreeType >::save_model | ( | std::string | path | ) |
Save Model to JSON encoded ".cmod" file.
| path | The path to save the file to |