Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions
xgboost::predictor::CPUPredictor Class Reference
Inheritance diagram for xgboost::predictor::CPUPredictor:
xgboost::Predictor

Public Member Functions

 CPUPredictor (Context const *ctx)
 
void PredictBatch (DMatrix *dmat, PredictionCacheEntry *predts, const gbm::GBTreeModel &model, uint32_t tree_begin, uint32_t tree_end=0) const override
 Generate batch predictions for a given feature matrix.
 
template<typename Adapter , size_t kBlockSize>
void DispatchedInplacePredict (std::any const &x, std::shared_ptr< DMatrix > p_m, const gbm::GBTreeModel &model, float missing, PredictionCacheEntry *out_preds, uint32_t tree_begin, uint32_t tree_end) const
 
bool InplacePredict (std::shared_ptr< DMatrix > p_m, const gbm::GBTreeModel &model, float missing, PredictionCacheEntry *out_preds, uint32_t tree_begin, unsigned tree_end) const override
 
void PredictInstance (const SparsePage::Inst &inst, std::vector< bst_float > *out_preds, const gbm::GBTreeModel &model, unsigned ntree_limit, bool is_column_split) const override
 online prediction function, predict score for one instance at a time NOTE: use the batch prediction interface if possible, batch prediction is usually more efficient than online prediction This function is NOT threadsafe, make sure you only call from one thread.
 
void PredictLeaf (DMatrix *p_fmat, HostDeviceVector< bst_float > *out_preds, const gbm::GBTreeModel &model, unsigned ntree_limit) const override
 predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in gbtree predictor.
 
void PredictContribution (DMatrix *p_fmat, HostDeviceVector< float > *out_contribs, const gbm::GBTreeModel &model, uint32_t ntree_limit, std::vector< bst_float > const *tree_weights, bool approximate, int condition, unsigned condition_feature) const override
 
void PredictInteractionContributions (DMatrix *p_fmat, HostDeviceVector< bst_float > *out_contribs, const gbm::GBTreeModel &model, unsigned ntree_limit, std::vector< bst_float > const *tree_weights, bool approximate) const override
 
- Public Member Functions inherited from xgboost::Predictor
 Predictor (Context const *ctx)
 
virtual void Configure (Args const &)
 Configure and register input matrices in prediction cache.
 
void InitOutPredictions (const MetaInfo &info, HostDeviceVector< bst_float > *out_predt, const gbm::GBTreeModel &model) const
 Initialize output prediction.
 
virtual bool InplacePredict (std::shared_ptr< DMatrix > p_fmat, const gbm::GBTreeModel &model, float missing, PredictionCacheEntry *out_preds, uint32_t tree_begin=0, uint32_t tree_end=0) const =0
 Inplace prediction.
 
virtual void PredictContribution (DMatrix *dmat, HostDeviceVector< bst_float > *out_contribs, const gbm::GBTreeModel &model, unsigned tree_end=0, std::vector< bst_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) * num_output_group * nsample, arranged in that order.
 

Protected Member Functions

void PredictDMatrix (DMatrix *p_fmat, std::vector< bst_float > *out_preds, gbm::GBTreeModel const &model, int32_t tree_begin, int32_t tree_end) const
 

Additional Inherited Members

- Static Public Member Functions inherited from xgboost::Predictor
static PredictorCreate (std::string const &name, Context const *ctx)
 Creates a new Predictor*.
 
- Protected Attributes inherited from xgboost::Predictor
Context const * ctx_
 

Member Function Documentation

◆ PredictBatch()

void xgboost::predictor::CPUPredictor::PredictBatch ( DMatrix dmat,
PredictionCacheEntry out_preds,
const gbm::GBTreeModel model,
uint32_t  tree_begin,
uint32_t  tree_end = 0 
) const
inlineoverridevirtual

Generate batch predictions for a given feature matrix.

May use cached predictions if available instead of calculating from scratch.

Parameters
[in,out]dmatFeature matrix.
[in,out]out_predsThe output preds.
modelThe model to predict from.
tree_beginThe tree begin index.
tree_endThe tree end index.

Implements xgboost::Predictor.

◆ PredictInstance()

void xgboost::predictor::CPUPredictor::PredictInstance ( const SparsePage::Inst inst,
std::vector< bst_float > *  out_preds,
const gbm::GBTreeModel model,
unsigned  tree_end,
bool  is_column_split 
) const
inlineoverridevirtual

online prediction function, predict score for one instance at a time NOTE: use the batch prediction interface if possible, batch prediction is usually more efficient than online prediction This function is NOT threadsafe, make sure you only call from one thread.

Parameters
instThe instance to predict.
[in,out]out_predsThe output preds.
modelThe model to predict from
tree_end(Optional) The tree end index.
is_column_split(Optional) If the data is split column-wise.

Implements xgboost::Predictor.

◆ PredictInteractionContributions()

void xgboost::predictor::CPUPredictor::PredictInteractionContributions ( DMatrix p_fmat,
HostDeviceVector< bst_float > *  out_contribs,
const gbm::GBTreeModel model,
unsigned  ntree_limit,
std::vector< bst_float > const *  tree_weights,
bool  approximate 
) const
inlineoverridevirtual

Implements xgboost::Predictor.

◆ PredictLeaf()

void xgboost::predictor::CPUPredictor::PredictLeaf ( DMatrix dmat,
HostDeviceVector< bst_float > *  out_preds,
const gbm::GBTreeModel model,
unsigned  tree_end 
) const
inlineoverridevirtual

predict the leaf index of each tree, the output will be nsample * ntree vector this is only valid in gbtree predictor.

Parameters
[in,out]dmatThe input feature matrix.
[in,out]out_predsThe output preds.
modelModel to make predictions from.
tree_end(Optional) The tree end index.

Implements xgboost::Predictor.


The documentation for this class was generated from the following file: