/** * Copyright (c) 2023, XGBoost Contributors */ #ifndef XGBOOST_OBJECTIVE_TEST_LAMBDARANK_OBJ_H_ #define XGBOOST_OBJECTIVE_TEST_LAMBDARANK_OBJ_H_ #include #include // for MetaInfo #include // for HostDeviceVector #include // for All #include // for ObjFunction #include // for shared_ptr, make_shared #include // for iota #include // for vector #include "../../../src/common/ranking_utils.h" // for LambdaRankParam, MAPCache #include "../../../src/objective/lambdarank_obj.h" // for MAPStat #include "../helpers.h" // for EmptyDMatrix namespace xgboost::obj { inline void TestNDCGJsonIO(Context const* ctx) { std::unique_ptr obj{ObjFunction::Create("rank:ndcg", ctx)}; obj->Configure(Args{}); Json j_obj{Object()}; obj->SaveConfig(&j_obj); ASSERT_EQ(get(j_obj["name"]), "rank:ndcg"); auto const& j_param = j_obj["lambdarank_param"]; ASSERT_EQ(get(j_param["ndcg_exp_gain"]), "1"); ASSERT_EQ(get(j_param["lambdarank_num_pair_per_sample"]), std::to_string(ltr::LambdaRankParam::NotSet())); } void TestNDCGGPair(Context const* ctx); void TestUnbiasedNDCG(Context const* ctx); /** * \brief Initialize test data for make pair tests. */ void InitMakePairTest(Context const* ctx, MetaInfo* out_info, HostDeviceVector* out_predt); } // namespace xgboost::obj #endif // XGBOOST_OBJECTIVE_TEST_LAMBDARANK_OBJ_H_