8 #include <dmlc/registry.h>
51 std::size_t
static constexpr DefaultSize() {
return 64; }
55 std::shared_ptr<PredictionCacheEntry>
Cache(std::shared_ptr<DMatrix> m,
DeviceOrd device) {
57 if (!device.
IsCPU()) {
58 p_cache->predictions.SetDevice(device);
96 const gbm::GBTreeModel& model)
const;
109 gbm::GBTreeModel
const& model,
bst_tree_t tree_begin,
111 std::vector<float>
const* tree_weights =
nullptr)
const = 0;
126 virtual bool InplacePredict(std::shared_ptr<DMatrix> p_fmat,
const gbm::GBTreeModel& model,
129 std::vector<float>
const* tree_weights =
nullptr)
const = 0;
142 gbm::GBTreeModel
const& model,
bst_tree_t tree_end = 0)
const = 0;
160 gbm::GBTreeModel
const& model,
bst_tree_t tree_end = 0,
161 std::vector<float>
const* tree_weights =
nullptr,
162 bool approximate =
false,
int condition = 0,
163 unsigned condition_feature = 0)
const = 0;
166 gbm::GBTreeModel
const& model,
168 std::vector<float>
const* tree_weights =
nullptr,
169 bool approximate =
false)
const = 0;
184 :
public dmlc::FunctionRegEntryBase<PredictorReg, std::function<Predictor*(Context const*)>> {};
186 #define XGBOOST_REGISTER_PREDICTOR(UniqueId, Name) \
187 static DMLC_ATTRIBUTE_UNUSED ::xgboost::PredictorReg& __make_##PredictorReg##_##UniqueId##__ = \
188 ::dmlc::Registry<::xgboost::PredictorReg>::Get()->__REGISTER__(Name)
Defines configuration macros and basic types for xgboost.
Thread-aware FIFO cache for DMatrix related data.
Definition: cache.h:26
std::shared_ptr< PredictionCacheEntry > CacheItem(std::shared_ptr< DMatrix > m, Args const &... args)
Cache a new DMatrix if it's not in the cache already.
Definition: cache.h:145
Internal data structured used by XGBoost to hold all external data.
Definition: data.h:577
A container for managed prediction caches.
Definition: predictor.h:49
std::shared_ptr< PredictionCacheEntry > Cache(std::shared_ptr< DMatrix > m, DeviceOrd device)
Definition: predictor.h:55
PredictionContainer()
Definition: predictor.h:54
Performs prediction on individual training instances or batches of instances for GBTree....
Definition: predictor.h:72
virtual void InitOutPredictions(const MetaInfo &info, HostDeviceVector< float > *out_predt, const gbm::GBTreeModel &model) const
Initialize output prediction.
virtual void Configure(Args const &)
Configure and register input matrices in prediction cache.
Predictor(Context const *ctx)
Definition: predictor.h:77
virtual void PredictContribution(DMatrix *dmat, HostDeviceVector< float > *out_contribs, gbm::GBTreeModel const &model, bst_tree_t tree_end=0, std::vector< float > const *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) *...
Context const * ctx_
Definition: predictor.h:74
virtual void PredictBatch(DMatrix *dmat, PredictionCacheEntry *out_preds, gbm::GBTreeModel const &model, bst_tree_t tree_begin, bst_tree_t tree_end=0, std::vector< float > const *tree_weights=nullptr) const =0
Generate batch predictions for a given feature matrix. May use cached predictions if available instea...
static Predictor * Create(std::string const &name, Context const *ctx)
Creates a new Predictor*.
virtual ~Predictor()=default
virtual void PredictLeaf(DMatrix *dmat, HostDeviceVector< float > *out_preds, gbm::GBTreeModel const &model, bst_tree_t tree_end=0) const =0
predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in ...
virtual void PredictInteractionContributions(DMatrix *dmat, HostDeviceVector< float > *out_contribs, gbm::GBTreeModel const &model, bst_tree_t tree_end=0, std::vector< float > const *tree_weights=nullptr, bool approximate=false) const =0
virtual bool InplacePredict(std::shared_ptr< DMatrix > p_fmat, const gbm::GBTreeModel &model, float missing, PredictionCacheEntry *out_preds, bst_tree_t tree_begin=0, bst_tree_t tree_end=0, std::vector< float > const *tree_weights=nullptr) const =0
Inplace prediction.
The input data structure of xgboost.
A device-and-host vector abstraction layer.
Definition: linear_updater.h:23
Learner interface that integrates objective, gbm and evaluation together. This is the user facing XGB...
Definition: base.h:89
std::vector< std::pair< std::string, std::string > > Args
Definition: base.h:306
std::int32_t bst_tree_t
Type for indexing trees.
Definition: base.h:127
Runtime context for XGBoost. Contains information like threads and device.
Definition: context.h:142
A type for device ordinal. The type is packed into 32-bit for efficient use in viewing types like lin...
Definition: context.h:40
bool IsCPU() const
Definition: context.h:56
Contains pointer to input matrix and associated cached predictions.
Definition: predictor.h:30
std::uint32_t version
Definition: predictor.h:34
HostDeviceVector< float > predictions
Definition: predictor.h:32
void Reset()
Definition: predictor.h:43
void Update(std::uint32_t v)
Update the cache entry by number of versions.
Definition: predictor.h:42
PredictionCacheEntry()=default
Registry entry for predictor.
Definition: predictor.h:184