From 5912e051b15d1a5a5cf1e4cdc31371c3af7dd0ad Mon Sep 17 00:00:00 2001 From: AbdealiJK Date: Sun, 4 Dec 2016 14:00:57 +0530 Subject: [PATCH] rank_metric.cc: Use GetWeight in EvalAMS The GetWeight is a wrapper which sets the correct weight if the weights vector is not provided. Hence accessing the default weights vector is not recommended. --- src/metric/rank_metric.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/metric/rank_metric.cc b/src/metric/rank_metric.cc index 86f27301e..d31c30180 100644 --- a/src/metric/rank_metric.cc +++ b/src/metric/rank_metric.cc @@ -33,7 +33,6 @@ struct EvalAMS : public Metric { using namespace std; // NOLINT(*) const bst_omp_uint ndata = static_cast(info.labels.size()); - CHECK_EQ(info.weights.size(), ndata) << "we need weight to evaluate ams"; std::vector > rec(ndata); #pragma omp parallel for schedule(static) @@ -48,7 +47,7 @@ struct EvalAMS : public Metric { double s_tp = 0.0, b_fp = 0.0, tams = 0.0; for (unsigned i = 0; i < static_cast(ndata-1) && i < ntop; ++i) { const unsigned ridx = rec[i].second; - const bst_float wt = info.weights[ridx]; + const bst_float wt = info.GetWeight(ridx); if (info.labels[ridx] > 0.5f) { s_tp += wt; } else {