From 5321fef67b5cc4711dd7b2de985d5fe2b76d90cf Mon Sep 17 00:00:00 2001 From: mjmckp Date: Wed, 17 Feb 2021 23:17:11 +1100 Subject: [PATCH] Fix for CreatePredictor function and VS2017 Debug build (#3937) * Fix index out-of-range exception generated by BaggingHelper on small datasets. Prior to this change, the line "score_t threshold = tmp_gradients[top_k - 1];" would generate an exception, since tmp_gradients would be empty when the cnt input value to the function is zero. * Update goss.hpp * Update goss.hpp * Add API method LGBM_BoosterPredictForMats which runs prediction on a data set given as of array of pointers to rows (as opposed to existing method LGBM_BoosterPredictForMat which requires data given as contiguous array) * Fix incorrect upstream merge * Add link to LightGBM.NET * Fix indenting to 2 spaces * Dummy edit to trigger CI * Dummy edit to trigger CI * remove duplicate functions from merge * Fix for CreatePredictor function: for VS2017 in Debug build, the previous version would end up giving an uninitialised prediction function that would throw access violation exceptions when invoked. Co-authored-by: matthew-peacock Co-authored-by: Guolin Ke --- src/c_api.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/c_api.cpp b/src/c_api.cpp index 47d7f8fef8de..b0f828f5072f 100644 --- a/src/c_api.cpp +++ b/src/c_api.cpp @@ -416,9 +416,8 @@ class Booster { is_raw_score = false; } - Predictor predictor(boosting_.get(), start_iteration, num_iteration, is_raw_score, is_predict_leaf, predict_contrib, + return Predictor(boosting_.get(), start_iteration, num_iteration, is_raw_score, is_predict_leaf, predict_contrib, config.pred_early_stop, config.pred_early_stop_freq, config.pred_early_stop_margin); - return predictor; } void Predict(int start_iteration, int num_iteration, int predict_type, int nrow, int ncol,