Unverified Commit df8c10ba authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

remove unused `DCGCalculator::CalDCGAtK()` (#4650)

parent 4b140bcc
...@@ -70,17 +70,6 @@ class DCGCalculator { ...@@ -70,17 +70,6 @@ class DCGCalculator {
*/ */
static void Init(const std::vector<double>& label_gain); static void Init(const std::vector<double>& label_gain);
/*!
* \brief Calculate the DCG score at position k
* \param k The position to evaluate
* \param label Pointer of label
* \param score Pointer of score
* \param num_data Number of data
* \return The DCG score
*/
static double CalDCGAtK(data_size_t k, const label_t* label,
const double* score, data_size_t num_data);
/*! /*!
* \brief Calculate the DCG score at multi position * \brief Calculate the DCG score at multi position
* \param ks The positions to evaluate * \param ks The positions to evaluate
......
...@@ -106,27 +106,6 @@ void DCGCalculator::CalMaxDCG(const std::vector<data_size_t>& ks, ...@@ -106,27 +106,6 @@ void DCGCalculator::CalMaxDCG(const std::vector<data_size_t>& ks,
} }
} }
double DCGCalculator::CalDCGAtK(data_size_t k, const label_t* label,
const double* score, data_size_t num_data) {
// get sorted indices by score
std::vector<data_size_t> sorted_idx(num_data);
for (data_size_t i = 0; i < num_data; ++i) {
sorted_idx[i] = i;
}
std::stable_sort(sorted_idx.begin(), sorted_idx.end(),
[score](data_size_t a, data_size_t b) {return score[a] > score[b]; });
if (k > num_data) { k = num_data; }
double dcg = 0.0f;
// calculate dcg
for (data_size_t i = 0; i < k; ++i) {
data_size_t idx = sorted_idx[i];
dcg += label_gain_[static_cast<int>(label[idx])] * discount_[i];
}
return dcg;
}
void DCGCalculator::CalDCG(const std::vector<data_size_t>& ks, const label_t* label, void DCGCalculator::CalDCG(const std::vector<data_size_t>& ks, const label_t* label,
const double * score, data_size_t num_data, std::vector<double>* out) { const double * score, data_size_t num_data, std::vector<double>* out) {
// get sorted indices by score // get sorted indices by score
......
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