slim-trees icon indicating copy to clipboard operation
slim-trees copied to clipboard

Add support for linear trees and `num_cat > 0`

Open pavelzw opened this issue 2 years ago • 1 comments

In gbdt_model_text.cpp GBDT::LoadModelFromString we can see how a model string should look like in LGBM. When looking into tree.cpp Tree::Tree, we can see that there are linear trees as well as trees with num_cat > 0.

The current implementation doesn't support these options yet.

For testing purposes, we can generate linear trees using

regressor = lgb.LGBMRegressor(n_estimators=100, random_state=42, linear_trees=True)
regressor.fit(*generate_dataset(n_samples=10000))

pavelzw avatar Mar 10 '23 17:03 pavelzw

Just as reference: (feature name, number of values)

('num_leaves', 1)
('num_cat', 1)
('split_feature', 30)
('split_gain', 30)
('threshold', 30)
('decision_type', 30)
('left_child', 30)
('right_child', 30)
('leaf_value', 31)
('leaf_weight', 31)
('leaf_count', 31)
('internal_value', 30)
('internal_weight', 30)
('internal_count', 30)
('is_linear', 1)
('leaf_const', 31)
('num_features', 31)
('leaf_features', 217)
('leaf_coeff', 217)
('shrinkage', 1)

YYYasin19 avatar Mar 17 '23 14:03 YYYasin19