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

Function CreateTestModel

tests/cpp/predictor/test_predictor.h:20–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19namespace xgboost {
20inline std::unique_ptr<gbm::GBTreeModel> CreateTestModel(LearnerModelParam const* param,
21 Context const* ctx, size_t n_classes = 1) {
22 auto model = std::make_unique<gbm::GBTreeModel>(param, ctx);
23
24 for (size_t i = 0; i < n_classes; ++i) {
25 std::vector<std::unique_ptr<RegTree>> trees;
26 trees.push_back(std::unique_ptr<RegTree>(new RegTree));
27 if (i == 0) {
28 (*trees.back())[0].SetLeaf(1.5f);
29 (*trees.back()).Stat(0).sum_hess = 1.0f;
30 }
31 model->CommitModelGroup(std::move(trees), i);
32 }
33
34 return model;
35}
36
37inline auto CreatePredictorForTest(Context const* ctx) {
38 if (ctx->IsCPU()) {

Callers 2

TestBasicFunction · 0.85

Calls 2

SetLeafMethod · 0.80
CommitModelGroupMethod · 0.80

Tested by

no test coverage detected