diff --git a/regrank/xgboost_regrank_obj.hpp b/regrank/xgboost_regrank_obj.hpp index e0ef67f7a..5272b42fa 100644 --- a/regrank/xgboost_regrank_obj.hpp +++ b/regrank/xgboost_regrank_obj.hpp @@ -336,8 +336,15 @@ namespace xgboost{ public: virtual ~LambdaRankObj_NDCG(void){} - inline float DCG(const std::vector &labels){ - return 1.0; + inline float CalcDCG( const std::vector &labels ){ + double sumdcg = 0.0; + for( size_t i = 0; i < labels.size(); i ++ ){ + const unsigned rel = labels[i]; + if( rel != 0 ){ + sumdcg += logf(2.0f) * ((1<(sumdcg); } inline float GetIDCG(const std::vector &sorted_list){ @@ -347,7 +354,7 @@ namespace xgboost{ } std::sort(labels.begin(), labels.end(), std::greater()); - return DCG(labels); + return CalcDCG(labels); } /*