16 #include <unordered_map> 39 uint32_t version { 0 };
41 std::weak_ptr< DMatrix >
ref;
56 std::unordered_map<DMatrix *, PredictionCacheEntry> container_;
57 void ClearExpiredEntries();
92 decltype(container_)
const& Container();
112 generic_param_{generic_param} {}
120 virtual void Configure(
const std::vector<std::pair<std::string, std::string>>& cfg);
134 const gbm::GBTreeModel& model,
int tree_begin,
135 uint32_t
const ntree_limit = 0) = 0;
146 virtual void InplacePredict(dmlc::any
const &x,
const gbm::GBTreeModel &model,
148 uint32_t tree_begin = 0, uint32_t tree_end = 0)
const = 0;
162 std::vector<bst_float>* out_preds,
163 const gbm::GBTreeModel& model,
164 unsigned ntree_limit = 0) = 0;
180 virtual void PredictLeaf(
DMatrix* dmat, std::vector<bst_float>* out_preds,
181 const gbm::GBTreeModel& model,
182 unsigned ntree_limit = 0) = 0;
203 virtual void PredictContribution(
DMatrix* dmat,
204 std::vector<bst_float>* out_contribs,
205 const gbm::GBTreeModel& model,
206 unsigned ntree_limit = 0,
207 std::vector<bst_float>* tree_weights =
nullptr,
208 bool approximate =
false,
210 unsigned condition_feature = 0) = 0;
212 virtual void PredictInteractionContributions(
DMatrix* dmat,
213 std::vector<bst_float>* out_contribs,
214 const gbm::GBTreeModel& model,
215 unsigned ntree_limit = 0,
216 std::vector<bst_float>* tree_weights =
nullptr,
217 bool approximate =
false) = 0;
234 :
public dmlc::FunctionRegEntryBase<
235 PredictorReg, std::function<Predictor*(GenericParameter const*)>> {};
237 #define XGBOOST_REGISTER_PREDICTOR(UniqueId, Name) \ 238 static DMLC_ATTRIBUTE_UNUSED ::xgboost::PredictorReg& \ 239 __make_##PredictorReg##_##UniqueId##__ = \ 240 ::dmlc::Registry<::xgboost::PredictorReg>::Get()->__REGISTER__(Name)
Performs prediction on individual training instances or batches of instances for GBTree. Prediction functions all take a GBTreeModel and a DMatrix as input and output a vector of predictions. The predictor does not modify any state of the model itself.
Definition: predictor.h:103
The input data structure of xgboost.
Definition: generic_parameters.h:14
Internal data structured used by XGBoost during training.
Definition: data.h:464
Registry entry for predictor.
Definition: predictor.h:233
A device-and-host vector abstraction layer.
GenericParameter const * generic_param_
Definition: predictor.h:108
span class implementation, based on ISO++20 span<T>. The interface should be the same.
Definition: span.h:126
Predictor(GenericParameter const *generic_param)
Definition: predictor.h:111
std::weak_ptr< DMatrix > ref
Definition: predictor.h:41
HostDeviceVector< bst_float > predictions
Definition: predictor.h:37
Definition: predictor.h:55
namespace of xgboost
Definition: base.h:102
defines configuration macros of xgboost.
void Update(uint32_t v)
Definition: predictor.h:48
Element from a sparse vector.
Definition: data.h:201
Contains pointer to input matrix and associated cached predictions.
Definition: predictor.h:35