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

Method PredictRawByMap

src/boosting/gbdt_prediction.cpp:39–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39void GBDT::PredictRawByMap(const std::unordered_map<int, double>& features, double* output, const PredictionEarlyStopInstance* early_stop) const {
40 int early_stop_round_counter = 0;
41 // set zero
42 std::memset(output, 0, sizeof(double) * num_tree_per_iteration_);
43 for (int i = 0; i < num_iteration_for_pred_; ++i) {
44 // predict all the trees for one iteration
45 for (int k = 0; k < num_tree_per_iteration_; ++k) {
46 output[k] += models_[i * num_tree_per_iteration_ + k]->PredictByMap(features);
47 }
48 // check early stopping
49 ++early_stop_round_counter;
50 if (early_stop->round_period == early_stop_round_counter) {
51 if (early_stop->callback_function(output, num_tree_per_iteration_)) {
52 return;
53 }
54 early_stop_round_counter = 0;
55 }
56 }
57}
58
59void GBDT::Predict(const double* features, double* output, const PredictionEarlyStopInstance* early_stop) const {
60 PredictRaw(features, output, early_stop);

Callers 1

PredictorMethod · 0.45

Calls 1

PredictByMapMethod · 0.45

Tested by

no test coverage detected