8 #ifndef XGBOOST_LEARNER_H_ 9 #define XGBOOST_LEARNER_H_ 11 #include <rabit/rabit.h> 27 class GradientBooster;
81 const std::vector<DMatrix*>& data_sets,
82 const std::vector<std::string>& data_names) = 0;
98 unsigned ntree_limit = 0,
99 bool training =
false,
100 bool pred_leaf =
false,
101 bool pred_contribs =
false,
102 bool approx_contribs =
false,
103 bool pred_interactions =
false) = 0;
108 virtual void LoadModel(dmlc::Stream* fi) = 0;
109 virtual void SaveModel(dmlc::Stream* fo)
const = 0;
125 virtual void SetParam(
const std::string& key,
const std::string& value) = 0;
135 virtual void SetAttr(
const std::string& key,
const std::string& value) = 0;
143 virtual bool GetAttr(
const std::string& key, std::string* out)
const = 0;
149 virtual bool DelAttr(
const std::string& key) = 0;
154 virtual std::vector<std::string>
GetAttrNames()
const = 0;
168 std::string format)
const = 0;
174 static Learner*
Create(
const std::vector<std::shared_ptr<DMatrix> >& cache_data);
185 std::unique_ptr<ObjFunction>
obj_;
187 std::unique_ptr<GradientBooster>
gbm_;
194 struct LearnerModelParamLegacy;
216 #endif // XGBOOST_LEARNER_H_ virtual void Configure()=0
Configure Learner based on set parameters.
virtual void BoostOneIter(int iter, DMatrix *train, HostDeviceVector< GradientPair > *in_gpair)=0
Do customized gradient boosting with in_gpair. in_gair can be mutated after this call.
float bst_float
float type, used for storing statistics
Definition: base.h:111
std::vector< std::unique_ptr< Metric > > metrics_
The evaluation metrics used to evaluate the model.
Definition: learner.h:189
Definition: learner.h:199
virtual bool DelAttr(const std::string &key)=0
Delete an attribute from the booster.
virtual void UpdateOneIter(int iter, DMatrix *train)=0
update the model for one iteration With the specified objective function.
virtual void SetAttr(const std::string &key, const std::string &value)=0
Set additional attribute to the Booster.
Definition: host_device_vector.h:85
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:238
virtual void Predict(DMatrix *data, bool output_margin, HostDeviceVector< bst_float > *out_preds, unsigned ntree_limit=0, bool training=false, bool pred_leaf=false, bool pred_contribs=false, bool approx_contribs=false, bool pred_interactions=false)=0
get prediction given the model.
bool AllowLazyCheckPoint() const
Definition: generic_parameters.h:14
Defines the abstract interface for different components in XGBoost.
static Learner * Create(const std::vector< std::shared_ptr< DMatrix > > &cache_data)
Create a new instance of learner.
virtual void SetParams(Args const &args)=0
Set multiple parameters at once.
std::unique_ptr< GradientBooster > gbm_
The gradient booster used by the model.
Definition: learner.h:187
Internal data structured used by XGBoost during training. There are two ways to create a customized D...
Definition: data.h:428
A device-and-host vector abstraction layer.
bool Initialized() const
Definition: learner.h:212
Feature map data structure to help text model dump. TODO(tqchen) consider make it even more lightweig...
Definition: feature_map.h:22
bst_float base_score
Definition: learner.h:201
virtual bool GetAttr(const std::string &key, std::string *out) const =0
Get attribute from the booster. The property will be saved along the booster.
~Learner() override
virtual destructor
uint32_t num_output_group
Definition: learner.h:205
std::unique_ptr< ObjFunction > obj_
objective function
Definition: learner.h:185
Feature map data structure to help visualization and model dump.
namespace of xgboost
Definition: base.h:102
LearnerModelParam()
Definition: learner.h:207
virtual GenericParameter const & GetGenericParameter() const =0
void SaveModel(Json *out) const override=0
saves the model config to a json object
defines configuration macros of xgboost.
uint32_t num_feature
Definition: learner.h:203
Learner class that does training and prediction. This is the user facing module of xgboost training...
Definition: learner.h:48
void LoadModel(Json const &in) override=0
load the model from a json object
virtual std::vector< std::string > GetAttrNames() const =0
Get a vector of attribute names from the booster.
Data structure representing JSON format.
Definition: json.h:325
virtual std::string EvalOneIter(int iter, const std::vector< DMatrix *> &data_sets, const std::vector< std::string > &data_names)=0
evaluate the model for specific iteration using the configured metrics.
virtual const std::map< std::string, std::string > & GetConfigurationArguments() const =0
Get configuration arguments currently stored by the learner.
virtual std::vector< std::string > DumpModel(const FeatureMap &fmap, bool with_stats, std::string format) const =0
dump the model in the requested format
GenericParameter generic_parameters_
Training parameter.
Definition: learner.h:191
virtual void SetParam(const std::string &key, const std::string &value)=0
Set parameter for booster.