MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / PredictSingleRow

Method PredictSingleRow

src/c_api.cpp:257–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255 }
256
257 void PredictSingleRow(int num_iteration, int predict_type, int ncol,
258 std::function<std::vector<std::pair<int, double>>(int row_idx)> get_row_fun,
259 const Config& config,
260 double* out_result, int64_t* out_len) {
261 if (ncol != boosting_->MaxFeatureIdx() + 1) {
262 Log::Fatal("The number of features in data (%d) is not the same as it was in training data (%d).", ncol, boosting_->MaxFeatureIdx() + 1);
263 }
264 std::lock_guard<std::mutex> lock(mutex_);
265 if (single_row_predictor_[predict_type].get() == nullptr ||
266 !single_row_predictor_[predict_type]->IsPredictorEqual(config, num_iteration, boosting_.get())) {
267 single_row_predictor_[predict_type].reset(new SingleRowPredictor(predict_type, boosting_.get(),
268 config, num_iteration));
269 }
270 auto one_row = get_row_fun(0);
271 auto pred_wrt_ptr = out_result;
272 single_row_predictor_[predict_type]->predict_function(one_row, pred_wrt_ptr);
273
274 *out_len = single_row_predictor_[predict_type]->num_pred_in_one_row;
275 }
276
277
278 void Predict(int num_iteration, int predict_type, int nrow, int ncol,

Calls 4

resetMethod · 0.80
MaxFeatureIdxMethod · 0.45
getMethod · 0.45
IsPredictorEqualMethod · 0.45

Tested by

no test coverage detected