Medial Code Documentation
|
The interface for Boosting. More...
#include <boosting.h>
Public Member Functions | |
virtual | ~Boosting () |
virtual destructor | |
virtual void | Init (const Config *config, const Dataset *train_data, const ObjectiveFunction *objective_function, const std::vector< const Metric * > &training_metrics)=0 |
Initialization logic. | |
virtual void | MergeFrom (const Boosting *other)=0 |
Merge model from other boosting object Will insert to the front of current boosting object. | |
virtual void | ShuffleModels (int start_iter, int end_iter)=0 |
Shuffle Existing Models. | |
virtual void | ResetTrainingData (const Dataset *train_data, const ObjectiveFunction *objective_function, const std::vector< const Metric * > &training_metrics)=0 |
virtual void | ResetConfig (const Config *config)=0 |
virtual void | AddValidDataset (const Dataset *valid_data, const std::vector< const Metric * > &valid_metrics)=0 |
Add a validation data. | |
virtual void | Train (int snapshot_freq, const std::string &model_output_path)=0 |
virtual void | RefitTree (const std::vector< std::vector< int > > &tree_leaf_prediction)=0 |
Update the tree output by new training data. | |
virtual bool | TrainOneIter (const score_t *gradients, const score_t *hessians)=0 |
Training logic. | |
virtual void | RollbackOneIter ()=0 |
Rollback one iteration. | |
virtual int | GetCurrentIteration () const =0 |
return current iteration | |
virtual std::vector< double > | GetEvalAt (int data_idx) const =0 |
Get evaluation result at data_idx data. | |
virtual const double * | GetTrainingScore (int64_t *out_len)=0 |
Get current training score. | |
virtual int64_t | GetNumPredictAt (int data_idx) const =0 |
Get prediction result at data_idx data. | |
virtual void | GetPredictAt (int data_idx, double *result, int64_t *out_len)=0 |
Get prediction result at data_idx data. | |
virtual int | NumPredictOneRow (int num_iteration, bool is_pred_leaf, bool is_pred_contrib) const =0 |
virtual void | PredictRaw (const double *features, double *output, const PredictionEarlyStopInstance *early_stop) const =0 |
Prediction for one record, not sigmoid transform. | |
virtual void | PredictRawByMap (const std::unordered_map< int, double > &features, double *output, const PredictionEarlyStopInstance *early_stop) const =0 |
virtual void | Predict (const double *features, double *output, const PredictionEarlyStopInstance *early_stop) const =0 |
Prediction for one record, sigmoid transformation will be used if needed. | |
virtual void | PredictByMap (const std::unordered_map< int, double > &features, double *output, const PredictionEarlyStopInstance *early_stop) const =0 |
virtual void | PredictLeafIndex (const double *features, double *output) const =0 |
Prediction for one record with leaf index. | |
virtual void | PredictLeafIndexByMap (const std::unordered_map< int, double > &features, double *output) const =0 |
virtual void | PredictContrib (const double *features, double *output, const PredictionEarlyStopInstance *early_stop) const =0 |
Feature contributions for the model's prediction of one record. | |
virtual std::string | DumpModel (int start_iteration, int num_iteration) const =0 |
Dump model to json format string. | |
virtual std::string | ModelToIfElse (int num_iteration) const =0 |
Translate model to if-else statement. | |
virtual bool | SaveModelToIfElse (int num_iteration, const char *filename) const =0 |
Translate model to if-else statement. | |
virtual bool | SaveModelToFile (int start_iteration, int num_iterations, const char *filename) const =0 |
Save model to file. | |
std::string | SaveModelToString (int num_iterations) |
Save model to string. | |
virtual std::string | SaveModelToString (int start_iteration, int num_iterations) const =0 |
bool | LoadModelFromString (std::string str) |
Restore from a serialized string. | |
virtual bool | LoadModelFromString (const char *buffer, size_t len)=0 |
virtual std::vector< double > | FeatureImportance (int num_iteration, int importance_type) const =0 |
Calculate feature importances. | |
virtual int | MaxFeatureIdx () const =0 |
Get max feature index of this model. | |
virtual std::vector< std::string > | FeatureNames () const =0 |
Get feature names of this model. | |
virtual int | LabelIdx () const =0 |
Get index of label column. | |
virtual int | NumberOfTotalModel () const =0 |
Get number of weak sub-models. | |
virtual int | NumModelPerIteration () const =0 |
Get number of models per iteration. | |
virtual int | NumberOfClasses () const =0 |
Get number of classes. | |
virtual bool | NeedAccuratePrediction () const =0 |
The prediction should be accurate or not. True will disable early stopping for prediction. | |
virtual void | InitPredict (int num_iteration, bool is_pred_contrib)=0 |
Initial work for the prediction. | |
virtual const char * | SubModelName () const =0 |
Name of submodel. | |
Boosting & | operator= (const Boosting &)=delete |
Disable copy. | |
Boosting (const Boosting &)=delete | |
Disable copy. | |
Static Public Member Functions | |
static bool | LoadFileToBoosting (Boosting *boosting, const char *filename) |
static Boosting * | CreateBoosting (const std::string &type, const char *filename) |
Create boosting object. | |
The interface for Boosting.
|
pure virtual |
Add a validation data.
valid_data | Validation data |
valid_metrics | Metric for validation data |
Implemented in LightGBM::GBDT, and LightGBM::RF.
|
static |
Create boosting object.
type | Type of boosting |
format | Format of model |
config | config for boosting |
filename | name of model file, if existing will continue to train from this model |
|
pure virtual |
Dump model to json format string.
start_iteration | The model will be saved start from |
num_iteration | Number of iterations that want to dump, -1 means dump all |
Implemented in LightGBM::GBDT.
|
pure virtual |
Calculate feature importances.
num_iteration | Number of model that want to use for feature importance, -1 means use all |
importance_type | 0 for split, 1 for gain |
Implemented in LightGBM::GBDT.
|
pure virtual |
|
pure virtual |
return current iteration
Implemented in LightGBM::GBDT.
|
pure virtual |
Get evaluation result at data_idx data.
data_idx | 0: training data, 1: 1st validation data |
Implemented in LightGBM::GBDT.
|
pure virtual |
Get prediction result at data_idx data.
data_idx | 0: training data, 1: 1st validation data |
Implemented in LightGBM::GBDT.
|
pure virtual |
Get prediction result at data_idx data.
data_idx | 0: training data, 1: 1st validation data |
result | used to store prediction result, should allocate memory before call this function |
out_len | length of returned score |
Implemented in LightGBM::GBDT.
|
pure virtual |
Get current training score.
out_len | length of returned score |
Implemented in LightGBM::DART, and LightGBM::GBDT.
|
pure virtual |
Initialization logic.
config | Configs for boosting |
train_data | Training data |
objective_function | Training objective function |
training_metrics | Training metric |
Implemented in LightGBM::DART, LightGBM::GOSS, LightGBM::RF, and LightGBM::GBDT.
|
pure virtual |
Initial work for the prediction.
num_iteration | number of used iteration |
is_pred_contrib |
Implemented in LightGBM::GBDT.
|
pure virtual |
|
inline |
Restore from a serialized string.
buffer | The content of model |
len | The length of buffer |
|
pure virtual |
Get max feature index of this model.
Implemented in LightGBM::GBDT.
|
pure virtual |
Merge model from other boosting object Will insert to the front of current boosting object.
other |
Implemented in LightGBM::GBDT.
|
pure virtual |
Translate model to if-else statement.
num_iteration | Number of iterations that want to translate, -1 means translate all |
Implemented in LightGBM::GBDT.
|
pure virtual |
The prediction should be accurate or not. True will disable early stopping for prediction.
Implemented in LightGBM::GBDT, and LightGBM::RF.
|
pure virtual |
|
pure virtual |
|
pure virtual |
Get number of models per iteration.
Implemented in LightGBM::GBDT.
|
pure virtual |
Implemented in LightGBM::GBDT.
|
pure virtual |
Prediction for one record, sigmoid transformation will be used if needed.
feature_values | Feature value on this record |
output | Prediction result for this record |
early_stop | Early stopping instance. If nullptr, no early stopping is applied and all models are evaluated. |
Implemented in LightGBM::GBDT.
|
pure virtual |
Feature contributions for the model's prediction of one record.
feature_values | Feature value on this record |
output | Prediction result for this record |
early_stop | Early stopping instance. If nullptr, no early stopping is applied and all models are evaluated. |
Implemented in LightGBM::GBDT.
|
pure virtual |
Prediction for one record with leaf index.
feature_values | Feature value on this record |
output | Prediction result for this record |
Implemented in LightGBM::GBDT.
|
pure virtual |
Prediction for one record, not sigmoid transform.
feature_values | Feature value on this record |
output | Prediction result for this record |
early_stop | Early stopping instance. If nullptr, no early stopping is applied and all models are evaluated. |
Implemented in LightGBM::GBDT.
|
pure virtual |
Update the tree output by new training data.
Implemented in LightGBM::GBDT.
|
pure virtual |
Implemented in LightGBM::GOSS, LightGBM::RF, and LightGBM::GBDT.
|
pure virtual |
Implemented in LightGBM::GBDT, LightGBM::GOSS, and LightGBM::RF.
|
pure virtual |
Rollback one iteration.
Implemented in LightGBM::GBDT, and LightGBM::RF.
|
pure virtual |
Save model to file.
start_iteration | The model will be saved start from |
num_iterations | Number of model that want to save, -1 means save all |
is_finish | Is training finished or not |
filename | Filename that want to save to |
Implemented in LightGBM::GBDT.
|
pure virtual |
Translate model to if-else statement.
num_iteration | Number of iterations that want to translate, -1 means translate all |
filename | Filename that want to save to |
Implemented in LightGBM::GBDT.
|
inline |
Save model to string.
start_iteration | The model will be saved start from |
num_iterations | Number of model that want to save, -1 means save all |
|
pure virtual |
Shuffle Existing Models.
Implemented in LightGBM::GBDT.
|
pure virtual |
Name of submodel.
Implemented in LightGBM::GBDT.
|
pure virtual |
Implemented in LightGBM::GBDT.
|
pure virtual |
Training logic.
gradients | nullptr for using default objective, otherwise use self-defined boosting |
hessians | nullptr for using default objective, otherwise use self-defined boosting |
Implemented in LightGBM::DART, LightGBM::GBDT, and LightGBM::RF.