You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Categorical splits are classifier/regressor-only; forest, Bagging and ExtraTree builders and traversals ignore cat_kind #457
Follow-up from #354 / PR #441, where this was scoped out deliberately and flagged only in a comment on the now-closed issue.
Current state, verified on main
TreeNode carries cat_kind and cat_mask0..3, and the two plain builders (decision_tree_classifier_fit_categorical, decision_tree_regressor_fit_categorical) plus their predict paths honour them. grep cat_kind lib/scikit/ensemble.flow returns nothing: the RandomForest, Bagging and ExtraTree builders never set it, and ensemble.flow's three inline node-traversal sites evaluate every node as a threshold split.
This is currently safe — node arrays are calloc'd (#403), so every node those builders produce has cat_kind == 0 and traversals behave correctly. But it means the headline feature of #441 (native categorical handling, the most-repeated community complaint the project catalogues) is unavailable exactly where sklearn users most want it: forests.
What a fix needs
Thread the per-feature categorical mask through random_forest_classifier_fit, the Bagging fits and ExtraTree.
Either route the three inline traversals in ensemble.flow through a shared node-evaluation helper that understands cat_kind, or teach each site the mask test. A shared helper is strongly preferable: three copies of set-membership logic is how the next inconsistency starts.
Cross-reference: #441 for the representation and the allocation-size audit discipline (the struct is 52 bytes, allocated at 64 — any new array of TreeNode must match).
Activity
test: categorical ensembles, seed stability and the max_features scope