Go to the documentation of this file.
16 #include <unordered_map>
41 std::weak_ptr< DMatrix >
ref;
56 std::unordered_map<DMatrix *, PredictionCacheEntry> container_;
57 void ClearExpiredEntries();
120 virtual void Configure(
const std::vector<std::pair<std::string, std::string>>&);
130 HostDeviceVector<bst_float> *out_predt,
131 const gbm::GBTreeModel &model)
const = 0;
143 virtual void PredictBatch(DMatrix* dmat, PredictionCacheEntry* out_preds,
144 const gbm::GBTreeModel& model, uint32_t tree_begin,
145 uint32_t tree_end = 0)
const = 0;
158 virtual bool InplacePredict(dmlc::any
const &x, std::shared_ptr<DMatrix> p_m,
159 const gbm::GBTreeModel &model,
float missing,
160 PredictionCacheEntry *out_preds,
161 uint32_t tree_begin = 0,
162 uint32_t tree_end = 0)
const = 0;
176 std::vector<bst_float>* out_preds,
177 const gbm::GBTreeModel& model,
178 unsigned tree_end = 0)
const = 0;
190 virtual void PredictLeaf(DMatrix* dmat, HostDeviceVector<bst_float>* out_preds,
191 const gbm::GBTreeModel& model,
192 unsigned tree_end = 0)
const = 0;
210 HostDeviceVector<bst_float>* out_contribs,
211 const gbm::GBTreeModel& model,
212 unsigned tree_end = 0,
213 std::vector<bst_float>* tree_weights =
nullptr,
214 bool approximate =
false,
216 unsigned condition_feature = 0)
const = 0;
219 HostDeviceVector<bst_float>* out_contribs,
220 const gbm::GBTreeModel& model,
221 unsigned tree_end = 0,
222 std::vector<bst_float>* tree_weights =
nullptr,
223 bool approximate =
false)
const = 0;
233 std::string
const& name, GenericParameter
const* generic_param);
240 :
public dmlc::FunctionRegEntryBase<
241 PredictorReg, std::function<Predictor*(GenericParameter const*)>> {};
243 #define XGBOOST_REGISTER_PREDICTOR(UniqueId, Name) \
244 static DMLC_ATTRIBUTE_UNUSED ::xgboost::PredictorReg& \
245 __make_##PredictorReg##_##UniqueId##__ = \
246 ::dmlc::Registry<::xgboost::PredictorReg>::Get()->__REGISTER__(Name)
virtual void PredictBatch(DMatrix *dmat, PredictionCacheEntry *out_preds, const gbm::GBTreeModel &model, uint32_t tree_begin, uint32_t tree_end=0) const =0
Generate batch predictions for a given feature matrix. May use cached predictions if available instea...
virtual ~Predictor()=default
virtual void Configure(const std::vector< std::pair< std::string, std::string >> &)
Configure and register input matrices in prediction cache.
Contains pointer to input matrix and associated cached predictions.
Definition: predictor.h:35
PredictionContainer()=default
virtual void PredictInteractionContributions(DMatrix *dmat, HostDeviceVector< bst_float > *out_contribs, const gbm::GBTreeModel &model, unsigned tree_end=0, std::vector< bst_float > *tree_weights=nullptr, bool approximate=false) const =0
Definition: generic_parameters.h:15
PredictionCacheEntry & Cache(std::shared_ptr< DMatrix > m, int32_t device)
void Update(uint32_t v)
Definition: predictor.h:48
A device-and-host vector abstraction layer.
defines configuration macros of xgboost.
uint32_t version
Definition: predictor.h:39
common::Span< Entry const > Inst
an instance of sparse vector in the batch
Definition: data.h:253
Internal data structured used by XGBoost during training.
Definition: data.h:449
Definition: predictor.h:55
PredictionCacheEntry & Entry(DMatrix *m)
HostDeviceVector< bst_float > predictions
Definition: predictor.h:37
virtual void PredictInstance(const SparsePage::Inst &inst, std::vector< bst_float > *out_preds, const gbm::GBTreeModel &model, unsigned tree_end=0) const =0
online prediction function, predict score for one instance at a time NOTE: use the batch prediction i...
Predictor(GenericParameter const *generic_param)
Definition: predictor.h:111
decltype(container_) const & Container()
PredictionCacheEntry()=default
virtual void PredictLeaf(DMatrix *dmat, HostDeviceVector< bst_float > *out_preds, const gbm::GBTreeModel &model, unsigned tree_end=0) const =0
predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in ...
GenericParameter const * generic_param_
Definition: predictor.h:108
virtual void InitOutPredictions(const MetaInfo &info, HostDeviceVector< bst_float > *out_predt, const gbm::GBTreeModel &model) const =0
Initialize output prediction.
The input data structure of xgboost.
Registry entry for predictor.
Definition: predictor.h:239
static Predictor * Create(std::string const &name, GenericParameter const *generic_param)
Creates a new Predictor*.
Performs prediction on individual training instances or batches of instances for GBTree....
Definition: predictor.h:103
virtual void PredictContribution(DMatrix *dmat, HostDeviceVector< bst_float > *out_contribs, const gbm::GBTreeModel &model, unsigned tree_end=0, std::vector< bst_float > *tree_weights=nullptr, bool approximate=false, int condition=0, unsigned condition_feature=0) const =0
feature contributions to individual predictions; the output will be a vector of length (nfeats + 1) *...
std::weak_ptr< DMatrix > ref
Definition: predictor.h:41
virtual bool InplacePredict(dmlc::any const &x, std::shared_ptr< DMatrix > p_m, const gbm::GBTreeModel &model, float missing, PredictionCacheEntry *out_preds, uint32_t tree_begin=0, uint32_t tree_end=0) const =0
Inplace prediction.
namespace of xgboost
Definition: base.h:110