correct CalcDCG in rank_metric.cc and rank_obj.cc (#1642)
* correct CalcDCG in rank_metric.cc DCG use log base-2, however `std::log` returns log base-e. * correct CalcDCG in rank_obj.cc DCG use log base-2, however `std::log` returns log base-e. * use std::log2 instead of std::log make it more elegant * use std::log2 instead of std::log make it more elegant
This commit is contained in:
@@ -215,7 +215,7 @@ class LambdaRankObjNDCG : public LambdaRankObj {
|
||||
for (size_t i = 0; i < labels.size(); ++i) {
|
||||
const unsigned rel = static_cast<unsigned>(labels[i]);
|
||||
if (rel != 0) {
|
||||
sumdcg += ((1 << rel) - 1) / std::log(static_cast<float>(i + 2));
|
||||
sumdcg += ((1 << rel) - 1) / std::log2(static_cast<float>(i + 2));
|
||||
}
|
||||
}
|
||||
return static_cast<float>(sumdcg);
|
||||
|
||||
Reference in New Issue
Block a user