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

Method PredictContrib

src/boosting/gbdt.cpp:702–721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700}
701
702void GBDT::PredictContrib(const double* features, double* output, const PredictionEarlyStopInstance* early_stop) const {
703 int early_stop_round_counter = 0;
704 // set zero
705 const int num_features = max_feature_idx_ + 1;
706 std::memset(output, 0, sizeof(double) * num_tree_per_iteration_ * (num_features + 1));
707 for (int i = 0; i < num_iteration_for_pred_; ++i) {
708 // predict all the trees for one iteration
709 for (int k = 0; k < num_tree_per_iteration_; ++k) {
710 models_[i * num_tree_per_iteration_ + k]->PredictContrib(features, num_features, output + k*(num_features + 1));
711 }
712 // check early stopping
713 ++early_stop_round_counter;
714 if (early_stop->round_period == early_stop_round_counter) {
715 if (early_stop->callback_function(output, num_tree_per_iteration_)) {
716 return;
717 }
718 early_stop_round_counter = 0;
719 }
720 }
721}
722
723void GBDT::GetPredictAt(int data_idx, double* out_result, int64_t* out_len) {
724 CHECK(data_idx >= 0 && data_idx <= static_cast<int>(valid_score_updater_.size()));

Callers 1

PredictorMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected