Medial Code Documentation
|
learner that performs gradient boosting for a specific objective function. It does training and prediction. More...
Public Member Functions | |
LearnerImpl (std::vector< std::shared_ptr< DMatrix > > cache) | |
std::vector< std::string > | DumpModel (const FeatureMap &fmap, bool with_stats, std::string format) override |
dump the model in the requested format | |
Learner * | Slice (bst_layer_t begin, bst_layer_t end, bst_layer_t step, bool *out_of_bound) override |
Slice the model. | |
void | UpdateOneIter (int iter, std::shared_ptr< DMatrix > train) override |
update the model for one iteration With the specified objective function. | |
void | BoostOneIter (int iter, std::shared_ptr< DMatrix > train, HostDeviceVector< GradientPair > *in_gpair) override |
Do customized gradient boosting with in_gpair. in_gair can be mutated after this call. | |
std::string | EvalOneIter (int iter, const std::vector< std::shared_ptr< DMatrix > > &data_sets, const std::vector< std::string > &data_names) override |
evaluate the model for specific iteration using the configured metrics. | |
void | Predict (std::shared_ptr< DMatrix > data, bool output_margin, HostDeviceVector< bst_float > *out_preds, bst_layer_t layer_begin, bst_layer_t layer_end, bool training, bool pred_leaf, bool pred_contribs, bool approx_contribs, bool pred_interactions) override |
get prediction given the model. | |
int32_t | BoostedRounds () const override |
uint32_t | Groups () const override |
Get the number of output groups from the model. | |
XGBAPIThreadLocalEntry & | GetThreadLocal () const override |
void | InplacePredict (std::shared_ptr< DMatrix > p_m, PredictionType type, float missing, HostDeviceVector< float > **out_preds, bst_layer_t iteration_begin, bst_layer_t iteration_end) override |
Inplace prediction. | |
void | CalcFeatureScore (std::string const &importance_type, common::Span< int32_t const > trees, std::vector< bst_feature_t > *features, std::vector< float > *scores) override |
Calculate feature score. See doc in C API for outputs. | |
const std::map< std::string, std::string > & | GetConfigurationArguments () const override |
Get configuration arguments currently stored by the learner. | |
![]() | |
LearnerIO (std::vector< std::shared_ptr< DMatrix > > cache) | |
void | LoadModel (Json const &in) override |
load the model from a JSON object | |
void | SaveModel (Json *p_out) const override |
saves the model config to a JSON object | |
void | LoadModel (dmlc::Stream *fi) override |
void | SaveModel (dmlc::Stream *fo) const override |
void | Save (dmlc::Stream *fo) const override |
saves the model to a stream | |
void | Load (dmlc::Stream *fi) override |
load the model from a stream | |
![]() | |
LearnerConfiguration (std::vector< std::shared_ptr< DMatrix > > cache) | |
void | Configure () override |
Configure Learner based on set parameters. | |
void | CheckModelInitialized () const |
void | LoadConfig (Json const &in) override |
Load configuration from JSON object. | |
void | SaveConfig (Json *p_out) const override |
Save configuration to JSON object. | |
void | SetParam (const std::string &key, const std::string &value) override |
Set parameter for booster. | |
void | SetParams (std::vector< std::pair< std::string, std::string > > const &args) override |
Set multiple parameters at once. | |
uint32_t | GetNumFeature () const override |
Get the number of features of the booster. | |
void | SetAttr (const std::string &key, const std::string &value) override |
Set additional attribute to the Booster. | |
bool | GetAttr (const std::string &key, std::string *out) const override |
Get attribute from the booster. The property will be saved along the booster. | |
bool | DelAttr (const std::string &key) override |
Delete an attribute from the booster. | |
void | SetFeatureNames (std::vector< std::string > const &fn) override |
Set the feature names for current booster. | |
void | GetFeatureNames (std::vector< std::string > *fn) const override |
Get the feature names for current booster. | |
void | SetFeatureTypes (std::vector< std::string > const &ft) override |
Set the feature types for current booster. | |
void | GetFeatureTypes (std::vector< std::string > *p_ft) const override |
Get the feature types for current booster. | |
std::vector< std::string > | GetAttrNames () const override |
Get a vector of attribute names from the booster. | |
Context const * | Ctx () const override |
Return the context object of this Booster. | |
![]() | |
~Learner () override | |
virtual destructor | |
![]() | |
virtual | ~Serializable () |
virtual destructor | |
Protected Member Functions | |
void | PredictRaw (DMatrix *data, PredictionCacheEntry *out_preds, bool training, unsigned layer_begin, unsigned layer_end) const |
get un-transformed prediction | |
void | ValidateDMatrix (DMatrix *p_fmat, bool is_training) const |
![]() | |
void | ConfigureModelParamWithoutBaseScore () |
void | InitBaseScore (DMatrix const *p_fmat) |
Calculate the base_score based on input data. | |
Additional Inherited Members | |
![]() | |
static Learner * | Create (const std::vector< std::shared_ptr< DMatrix > > &cache_data) |
Create a new instance of learner. | |
![]() | |
std::atomic< bool > | need_configuration_ |
std::map< std::string, std::string > | cfg_ |
std::map< std::string, std::string > | attributes_ |
std::vector< std::string > | feature_names_ |
std::vector< std::string > | feature_types_ |
common::Monitor | monitor_ |
LearnerModelParamLegacy | mparam_ |
LearnerModelParam | learner_model_param_ |
LearnerTrainParam | tparam_ |
PredictionContainer | prediction_container_ |
std::vector< std::string > | metric_names_ |
![]() | |
std::unique_ptr< ObjFunction > | obj_ |
objective function | |
std::unique_ptr< GradientBooster > | gbm_ |
The gradient booster used by the model. | |
std::vector< std::unique_ptr< Metric > > | metrics_ |
The evaluation metrics used to evaluate the model. | |
Context | ctx_ |
Training parameter. | |
![]() | |
static std::string const | kEvalMetric {"eval_metric"} |
learner that performs gradient boosting for a specific objective function. It does training and prediction.
|
inlineoverridevirtual |
Implements xgboost::Learner.
|
inlineoverridevirtual |
Do customized gradient boosting with in_gpair. in_gair can be mutated after this call.
iter | current iteration number |
train | reference to the data matrix. |
in_gpair | The input gradient statistics. |
Implements xgboost::Learner.
|
inlineoverridevirtual |
Calculate feature score. See doc in C API for outputs.
Implements xgboost::Learner.
|
inlineoverridevirtual |
dump the model in the requested format
fmap | feature map that may help give interpretations of feature |
with_stats | extra statistics while dumping model |
format | the format to dump the model in |
Implements xgboost::Learner.
|
inlineoverridevirtual |
evaluate the model for specific iteration using the configured metrics.
iter | iteration number |
data_sets | datasets to be evaluated. |
data_names | name of each dataset |
Implements xgboost::Learner.
|
inlineoverridevirtual |
Get configuration arguments currently stored by the learner.
Reimplemented from xgboost::LearnerConfiguration.
|
inlineoverridevirtual |
Implements xgboost::Learner.
|
inlineoverridevirtual |
Get the number of output groups from the model.
Implements xgboost::Learner.
|
inlineoverridevirtual |
Inplace prediction.
p_fmat | A proxy DMatrix that contains the data and related meta info. | |
type | Prediction type. | |
missing | Missing value in the data. | |
[in,out] | out_preds | Pointer to output prediction vector. |
layer_begin | Beginning of boosted tree layer used for prediction. | |
layer_end | End of booster layer. 0 means do not limit trees. |
Implements xgboost::Learner.
|
inlineoverridevirtual |
get prediction given the model.
data | input data |
output_margin | whether to only predict margin value instead of transformed prediction |
out_preds | output vector that stores the prediction |
layer_begin | Beginning of boosted tree layer used for prediction. |
layer_end | End of booster layer. 0 means do not limit trees. |
training | Whether the prediction result is used for training |
pred_leaf | whether to only predict the leaf index of each tree in a boosted tree predictor |
pred_contribs | whether to only predict the feature contributions |
approx_contribs | whether to approximate the feature contributions for speed |
pred_interactions | whether to compute the feature pair contributions |
Implements xgboost::Learner.
|
inlineprotected |
get un-transformed prediction
data | training data matrix |
out_preds | output vector that stores the prediction |
ntree_limit | limit number of trees used for boosted tree predictor, when it equals 0, this means we are using all the trees |
training | allow dropout when the DART booster is being used |
|
inlineoverridevirtual |
Slice the model.
See InplacePredict for layer parameters.
step | step size between slice. |
out_of_bound | Return true if end layer is out of bound. |
Implements xgboost::Learner.
|
inlineoverridevirtual |
update the model for one iteration With the specified objective function.
iter | current iteration number |
train | reference to the data matrix. |
Implements xgboost::Learner.