sync Mar 27 2023
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright 2017-2022 XGBoost contributors
|
||||
/**
|
||||
* Copyright 2017-2023, XGBoost contributors
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/c_api.h>
|
||||
@@ -159,7 +159,7 @@ TEST(GPUPredictor, ShapStump) {
|
||||
|
||||
std::vector<std::unique_ptr<RegTree>> trees;
|
||||
trees.push_back(std::unique_ptr<RegTree>(new RegTree));
|
||||
model.CommitModel(std::move(trees), 0);
|
||||
model.CommitModelGroup(std::move(trees), 0);
|
||||
|
||||
auto gpu_lparam = CreateEmptyGenericParam(0);
|
||||
std::unique_ptr<Predictor> gpu_predictor = std::unique_ptr<Predictor>(
|
||||
@@ -187,7 +187,7 @@ TEST(GPUPredictor, Shap) {
|
||||
std::vector<std::unique_ptr<RegTree>> trees;
|
||||
trees.push_back(std::unique_ptr<RegTree>(new RegTree));
|
||||
trees[0]->ExpandNode(0, 0, 0.5, true, 1.0, -1.0, 1.0, 0.0, 5.0, 2.0, 3.0);
|
||||
model.CommitModel(std::move(trees), 0);
|
||||
model.CommitModelGroup(std::move(trees), 0);
|
||||
|
||||
auto gpu_lparam = CreateEmptyGenericParam(0);
|
||||
auto cpu_lparam = CreateEmptyGenericParam(-1);
|
||||
|
||||
@@ -209,7 +209,7 @@ void GBTreeModelForTest(gbm::GBTreeModel *model, uint32_t split_ind,
|
||||
p_tree->ExpandCategorical(0, split_ind, split_cats, true, 1.5f,
|
||||
left_weight, right_weight,
|
||||
3.0f, 2.2f, 7.0f, 9.0f);
|
||||
model->CommitModel(std::move(trees), 0);
|
||||
model->CommitModelGroup(std::move(trees), 0);
|
||||
}
|
||||
|
||||
void TestCategoricalPrediction(std::string name) {
|
||||
@@ -445,7 +445,7 @@ void TestVectorLeafPrediction(Context const *ctx) {
|
||||
ASSERT_TRUE(mparam.IsVectorLeaf());
|
||||
|
||||
gbm::GBTreeModel model{&mparam, ctx};
|
||||
model.CommitModel(std::move(trees), 0);
|
||||
model.CommitModelGroup(std::move(trees), 0);
|
||||
|
||||
auto run_test = [&](float expected, HostDeviceVector<float> *p_data) {
|
||||
{
|
||||
|
||||
@@ -14,6 +14,23 @@
|
||||
#include "../helpers.h"
|
||||
|
||||
namespace xgboost {
|
||||
inline gbm::GBTreeModel CreateTestModel(LearnerModelParam const* param, Context const* ctx,
|
||||
size_t n_classes = 1) {
|
||||
gbm::GBTreeModel model(param, ctx);
|
||||
|
||||
for (size_t i = 0; i < n_classes; ++i) {
|
||||
std::vector<std::unique_ptr<RegTree>> trees;
|
||||
trees.push_back(std::unique_ptr<RegTree>(new RegTree));
|
||||
if (i == 0) {
|
||||
(*trees.back())[0].SetLeaf(1.5f);
|
||||
(*trees.back()).Stat(0).sum_hess = 1.0f;
|
||||
}
|
||||
model.CommitModelGroup(std::move(trees), i);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
template <typename Page>
|
||||
void TestPredictionFromGradientIndex(std::string name, size_t rows, size_t cols,
|
||||
std::shared_ptr<DMatrix> p_hist) {
|
||||
|
||||
Reference in New Issue
Block a user