MCPcopy Create free account
hub / github.com/dmlc/xgboost / RankErrorForValue

Function RankErrorForValue

tests/cpp/common/test_quantile.h:492–507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492inline double RankErrorForValue(ReferenceColumn const& col, double target_rank, float queried) {
493 auto lo_it = std::lower_bound(col.values.cbegin(), col.values.cend(), queried);
494 auto hi_it = std::upper_bound(col.values.cbegin(), col.values.cend(), queried);
495 auto lo_idx = static_cast<std::size_t>(std::distance(col.values.cbegin(), lo_it));
496 auto hi_idx = static_cast<std::size_t>(std::distance(col.values.cbegin(), hi_it));
497 auto rank_lo = col.prefix_weights[lo_idx];
498 auto rank_hi = col.prefix_weights[hi_idx];
499
500 if (target_rank < rank_lo) {
501 return rank_lo - target_rank;
502 }
503 if (target_rank > rank_hi) {
504 return target_rank - rank_hi;
505 }
506 return 0.0;
507}
508
509template <typename Summary>
510double MaxSummaryQueryRankError(Summary const& summary, ReferenceColumn const& reference,

Callers 1

MaxSummaryQueryRankErrorFunction · 0.85

Calls 2

cbeginMethod · 0.45
cendMethod · 0.45

Tested by

no test coverage detected