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

Method PredictRaw

src/boosting/gbdt_prediction.cpp:13–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace LightGBM {
12
13void GBDT::PredictRaw(const double* features, double* output, const PredictionEarlyStopInstance* early_stop) const {
14 int early_stop_round_counter = 0;
15 // set zero
16 std::memset(output, 0, sizeof(double) * (num_tree_per_iteration_ + num_labels_ - 1));
17 for (int i = 0; i < num_iteration_for_pred_/num_labels_; ++i) {
18 // predict all the trees for one iteration
19 for (int k = 0; k < num_tree_per_iteration_; ++k) {
20 output[k] += models_[i * num_tree_per_iteration_ * num_labels_ + k]->Predict(features);
21 }
22
23 // TODO
24 for (int l = 1; l < num_labels_; ++l) {
25 output[num_tree_per_iteration_ - 1 + l] += models_[i * num_tree_per_iteration_ * num_labels_ + num_tree_per_iteration_ - 1 + l]->Predict(features);
26 }
27
28 // check early stopping
29 ++early_stop_round_counter;
30 if (early_stop->round_period == early_stop_round_counter) {
31 if (early_stop->callback_function(output, num_tree_per_iteration_)) {
32 return;
33 }
34 early_stop_round_counter = 0;
35 }
36 }
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;

Callers 1

PredictorMethod · 0.45

Calls 1

PredictMethod · 0.45

Tested by

no test coverage detected