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

Function GenerateCatDMatrix

tests/cpp/tree/test_column_split.h:15–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14namespace xgboost::tree {
15inline std::shared_ptr<DMatrix> GenerateCatDMatrix(std::size_t rows, std::size_t cols,
16 float sparsity, bool categorical) {
17 if (categorical) {
18 std::vector<FeatureType> ft(cols);
19 for (size_t i = 0; i < ft.size(); ++i) {
20 ft[i] = (i % 3 == 0) ? FeatureType::kNumerical : FeatureType::kCategorical;
21 }
22 return RandomDataGenerator(rows, cols, sparsity)
23 .Seed(3)
24 .Type(ft)
25 .MaxCategory(17)
26 .GenerateDMatrix();
27 } else {
28 return RandomDataGenerator{rows, cols, sparsity}.Seed(3).GenerateDMatrix();
29 }
30}
31
32void TestColumnSplit(bst_target_t n_targets, bool categorical, std::string name, float sparsity);
33} // namespace xgboost::tree

Callers 2

TESTFunction · 0.85
TestColumnSplitFunction · 0.85

Calls 6

RandomDataGeneratorClass · 0.85
GenerateDMatrixMethod · 0.80
MaxCategoryMethod · 0.80
SeedMethod · 0.80
sizeMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected