Commit 0f0eb69e authored by Guolin Ke's avatar Guolin Ke
Browse files

fix a bug in goss

parent e2835654
...@@ -126,6 +126,7 @@ public: ...@@ -126,6 +126,7 @@ public:
*r = i; *r = i;
}; };
// Note: k refer to index here. e.g. k=0 means get max number.
inline static int ArgMaxAtK(std::vector<VAL_T>* arr, int start, int end, int k) { inline static int ArgMaxAtK(std::vector<VAL_T>* arr, int start, int end, int k) {
if (start >= end - 1) { if (start >= end - 1) {
return start; return start;
......
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
data_size_t top_k = static_cast<data_size_t>(cnt * gbdt_config_->top_rate); data_size_t top_k = static_cast<data_size_t>(cnt * gbdt_config_->top_rate);
data_size_t other_k = static_cast<data_size_t>(cnt * gbdt_config_->other_rate); data_size_t other_k = static_cast<data_size_t>(cnt * gbdt_config_->other_rate);
top_k = std::max(1, top_k); top_k = std::max(1, top_k);
ArrayArgs<score_t>::ArgMaxAtK(&tmp_gradients, 0, static_cast<int>(tmp_gradients.size()), top_k); ArrayArgs<score_t>::ArgMaxAtK(&tmp_gradients, 0, static_cast<int>(tmp_gradients.size()), top_k - 1);
score_t threshold = tmp_gradients[top_k - 1]; score_t threshold = tmp_gradients[top_k - 1];
score_t multiply = static_cast<score_t>(cnt - top_k) / other_k; score_t multiply = static_cast<score_t>(cnt - top_k) / other_k;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment