Medial Code Documentation
|
#include <tree.h>
Public Member Functions | |
Tree (int max_leaves) | |
Constructor. | |
Tree (const char *str, size_t *used_len) | |
Construtor, from a string. | |
int | Split (int leaf, int feature, int real_feature, uint32_t threshold_bin, double threshold_double, double left_value, double right_value, int left_cnt, int right_cnt, float gain, MissingType missing_type, bool default_left) |
Performing a split on tree leaves. | |
int | SplitCategorical (int leaf, int feature, int real_feature, const uint32_t *threshold_bin, int num_threshold_bin, const uint32_t *threshold, int num_threshold, double left_value, double right_value, int left_cnt, int right_cnt, float gain, MissingType missing_type) |
Performing a split on tree leaves, with categorical feature. | |
double | LeafOutput (int leaf) const |
Get the output of one leaf. | |
void | SetLeafOutput (int leaf, double output) |
Set the output of one leaf. | |
void | AddPredictionToScore (const Dataset *data, data_size_t num_data, double *score) const |
Adding prediction value of this tree model to scores. | |
void | AddPredictionToScore (const Dataset *data, const data_size_t *used_data_indices, data_size_t num_data, double *score) const |
Adding prediction value of this tree model to scorese. | |
double | Predict (const double *feature_values) const |
Prediction on one record. | |
double | PredictByMap (const std::unordered_map< int, double > &feature_values) const |
int | PredictLeafIndex (const double *feature_values) const |
int | PredictLeafIndexByMap (const std::unordered_map< int, double > &feature_values) const |
void | PredictContrib (const double *feature_values, int num_features, double *output) |
int | num_leaves () const |
Get Number of leaves. | |
int | leaf_depth (int leaf_idx) const |
Get depth of specific leaf. | |
int | split_feature (int split_idx) const |
Get feature of specific split. | |
double | split_gain (int split_idx) const |
int | data_count (int node) const |
Get the number of data points that fall at or below this node. | |
void | Shrinkage (double rate) |
Shrinkage for the tree's output shrinkage rate (a.k.a learning rate) is used to tune the traning process. | |
double | shrinkage () const |
void | AddBias (double val) |
void | AsConstantTree (double val) |
std::string | ToString () const |
Serialize this object to string. | |
std::string | ToJSON () const |
Serialize this object to json. | |
std::string | ToIfElse (int index, bool predict_leaf_index) const |
Serialize this object to if-else statement. | |
void | RecomputeMaxDepth () |
Tree model.
|
explicit |
Constructor.
max_leaves | The number of max leaves |
LightGBM::Tree::Tree | ( | const char * | str, |
size_t * | used_len | ||
) |
Construtor, from a string.
str | Model string |
used_len | used count of str |
void LightGBM::Tree::AddPredictionToScore | ( | const Dataset * | data, |
const data_size_t * | used_data_indices, | ||
data_size_t | num_data, | ||
double * | score | ||
) | const |
Adding prediction value of this tree model to scorese.
data | The dataset |
used_data_indices | Indices of used data |
num_data | Number of total data |
score | Will add prediction to score |
void LightGBM::Tree::AddPredictionToScore | ( | const Dataset * | data, |
data_size_t | num_data, | ||
double * | score | ||
) | const |
Adding prediction value of this tree model to scores.
data | The dataset |
num_data | Number of total data |
score | Will add prediction to score |
|
inline |
Prediction on one record.
feature_values | Feature value of this record |
|
inline |
Shrinkage for the tree's output shrinkage rate (a.k.a learning rate) is used to tune the traning process.
rate | The factor of shrinkage |
int LightGBM::Tree::Split | ( | int | leaf, |
int | feature, | ||
int | real_feature, | ||
uint32_t | threshold_bin, | ||
double | threshold_double, | ||
double | left_value, | ||
double | right_value, | ||
int | left_cnt, | ||
int | right_cnt, | ||
float | gain, | ||
MissingType | missing_type, | ||
bool | default_left | ||
) |
Performing a split on tree leaves.
leaf | Index of leaf to be split |
feature | Index of feature; the converted index after removing useless features |
real_feature | Index of feature, the original index on data |
threshold_bin | Threshold(bin) of split |
threshold_double | Threshold on feature value |
left_value | Model Left child output |
right_value | Model Right child output |
left_cnt | Count of left child |
right_cnt | Count of right child |
gain | Split gain |
missing_type | missing type |
default_left | default direction for missing value |
int LightGBM::Tree::SplitCategorical | ( | int | leaf, |
int | feature, | ||
int | real_feature, | ||
const uint32_t * | threshold_bin, | ||
int | num_threshold_bin, | ||
const uint32_t * | threshold, | ||
int | num_threshold, | ||
double | left_value, | ||
double | right_value, | ||
int | left_cnt, | ||
int | right_cnt, | ||
float | gain, | ||
MissingType | missing_type | ||
) |
Performing a split on tree leaves, with categorical feature.
leaf | Index of leaf to be split |
feature | Index of feature; the converted index after removing useless features |
real_feature | Index of feature, the original index on data |
threshold_bin | Threshold(bin) of split, use bitset to represent |
num_threshold_bin | size of threshold_bin |
threshold | Thresholds of real feature value, use bitset to represent |
num_threshold | size of threshold |
left_value | Model Left child output |
right_value | Model Right child output |
left_cnt | Count of left child |
right_cnt | Count of right child |
gain | Split gain |