11/* *
2- * Copyright 2017-2024 , XGBoost Contributors
2+ * Copyright 2017-2025 , XGBoost Contributors
33 * \file predictor.h
44 * \brief Interface of predictor,
55 * performs predictions for a gradient booster.
@@ -28,7 +28,7 @@ namespace xgboost {
2828 */
2929struct PredictionCacheEntry {
3030 // A storage for caching prediction values
31- HostDeviceVector<bst_float > predictions;
31+ HostDeviceVector<float > predictions;
3232 // The version of current cache, corresponding number of layers of trees
3333 std::uint32_t version{0 };
3434
@@ -91,7 +91,7 @@ class Predictor {
9191 * \param out_predt Prediction vector to be initialized.
9292 * \param model Tree model used for prediction.
9393 */
94- virtual void InitOutPredictions (const MetaInfo& info, HostDeviceVector<bst_float >* out_predt,
94+ virtual void InitOutPredictions (const MetaInfo& info, HostDeviceVector<float >* out_predt,
9595 const gbm::GBTreeModel& model) const ;
9696
9797 /* *
@@ -105,8 +105,8 @@ class Predictor {
105105 * \param tree_end The tree end index.
106106 */
107107 virtual void PredictBatch (DMatrix* dmat, PredictionCacheEntry* out_preds,
108- const gbm::GBTreeModel& model, uint32_t tree_begin,
109- uint32_t tree_end = 0 ) const = 0;
108+ gbm::GBTreeModel const & model, bst_tree_t tree_begin,
109+ bst_tree_t tree_end = 0 ) const = 0;
110110
111111 /* *
112112 * \brief Inplace prediction.
@@ -123,25 +123,7 @@ class Predictor {
123123 */
124124 virtual bool InplacePredict (std::shared_ptr<DMatrix> p_fmat, const gbm::GBTreeModel& model,
125125 float missing, PredictionCacheEntry* out_preds,
126- uint32_t tree_begin = 0 , uint32_t tree_end = 0 ) const = 0;
127- /* *
128- * \brief online prediction function, predict score for one instance at a time
129- * NOTE: use the batch prediction interface if possible, batch prediction is
130- * usually more efficient than online prediction This function is NOT
131- * threadsafe, make sure you only call from one thread.
132- *
133- * \param inst The instance to predict.
134- * \param [in,out] out_preds The output preds.
135- * \param model The model to predict from
136- * \param tree_end (Optional) The tree end index.
137- * \param is_column_split (Optional) If the data is split column-wise.
138- */
139-
140- virtual void PredictInstance (const SparsePage::Inst& inst,
141- std::vector<bst_float>* out_preds,
142- const gbm::GBTreeModel& model,
143- unsigned tree_end = 0 ,
144- bool is_column_split = false ) const = 0;
126+ bst_tree_t tree_begin = 0 , bst_tree_t tree_end = 0 ) const = 0;
145127
146128 /* *
147129 * \brief predict the leaf index of each tree, the output will be nsample *
@@ -153,9 +135,8 @@ class Predictor {
153135 * \param tree_end (Optional) The tree end index.
154136 */
155137
156- virtual void PredictLeaf (DMatrix* dmat, HostDeviceVector<bst_float>* out_preds,
157- const gbm::GBTreeModel& model,
158- unsigned tree_end = 0 ) const = 0;
138+ virtual void PredictLeaf (DMatrix* dmat, HostDeviceVector<float >* out_preds,
139+ gbm::GBTreeModel const & model, bst_tree_t tree_end = 0 ) const = 0;
159140
160141 /* *
161142 * \brief feature contributions to individual predictions; the output will be
@@ -172,18 +153,17 @@ class Predictor {
172153 * \param condition_feature Feature to condition on (i.e. fix) during calculations.
173154 */
174155
175- virtual void
176- PredictContribution (DMatrix *dmat, HostDeviceVector<bst_float> *out_contribs,
177- const gbm::GBTreeModel &model, unsigned tree_end = 0 ,
178- std::vector<bst_float> const *tree_weights = nullptr ,
179- bool approximate = false , int condition = 0 ,
180- unsigned condition_feature = 0 ) const = 0 ;
181-
182- virtual void PredictInteractionContributions (
183- DMatrix *dmat, HostDeviceVector<bst_float> *out_contribs,
184- const gbm::GBTreeModel &model, unsigned tree_end = 0 ,
185- std::vector<bst_float> const *tree_weights = nullptr ,
186- bool approximate = false ) const = 0;
156+ virtual void PredictContribution (DMatrix* dmat, HostDeviceVector<float >* out_contribs,
157+ gbm::GBTreeModel const & model, bst_tree_t tree_end = 0 ,
158+ std::vector<float > const * tree_weights = nullptr ,
159+ bool approximate = false , int condition = 0 ,
160+ unsigned condition_feature = 0 ) const = 0;
161+
162+ virtual void PredictInteractionContributions (DMatrix* dmat, HostDeviceVector<float >* out_contribs,
163+ gbm::GBTreeModel const & model,
164+ bst_tree_t tree_end = 0 ,
165+ std::vector<float > const * tree_weights = nullptr ,
166+ bool approximate = false ) const = 0;
187167
188168 /* *
189169 * \brief Creates a new Predictor*.
0 commit comments