| 299 | class TestRegularization : public ::testing::Test { |
| 300 | public: |
| 301 | void Run(Context const* ctx, std::string const& updater, std::string p, bst_target_t n_targets) { |
| 302 | bst_idx_t n_samples = 4096; |
| 303 | bst_feature_t n_features = 32; |
| 304 | auto p_fmat = RandomDataGenerator(n_samples, n_features, .0f) |
| 305 | .Seed(3) |
| 306 | .Targets(n_targets) |
| 307 | .GenerateDMatrix(true); |
| 308 | auto gpairs = GenerateRandomGradients(ctx, n_samples, n_targets); |
| 309 | |
| 310 | RegTree tree_0{static_cast<bst_target_t>(gpairs.gpair.Shape(1)), |
| 311 | static_cast<bst_target_t>(p_fmat->Info().num_col_)}; |
| 312 | BuildTree(ctx, p_fmat.get(), &gpairs, updater, Args{{p, "0.0"}}, &tree_0); |
| 313 | // not exact, just checking the tree can be built |
| 314 | if (n_targets > 1) { |
| 315 | ASSERT_GE(tree_0.NumNodes(), 40); |
| 316 | } else { |
| 317 | ASSERT_GE(tree_0.NumNodes(), 50); |
| 318 | } |
| 319 | |
| 320 | RegTree tree_1{static_cast<bst_target_t>(gpairs.gpair.Shape(1)), |
| 321 | static_cast<bst_target_t>(p_fmat->Info().num_col_)}; |
| 322 | BuildTree(ctx, p_fmat.get(), &gpairs, updater, Args{{p, "1024.0"}}, &tree_1); |
| 323 | ASSERT_EQ(tree_1.NumNodes(), 1); |
| 324 | } |
| 325 | }; |
| 326 | |
| 327 | class TestLambda : public TestRegularization { |
nothing calls this directly
no test coverage detected