dmlc / dmlc/xgboost

What does max_cat_threshold actually control?

Open
#10,844 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
28.8k
Forks
8.9k
Avg merge
1d 12h
Merged PRs (30d)
54

Description

__TL;DR: I'd like to know what exactly `max_cat_threshold` controls and I may suggest marginal improvements of the documentation.__

----

I'm quite interested in XGBoost's support for categorical features. I dived into the documentation, but can't understand the exact effect of `max_cat_threshold`. By reading the C++ code ([here](https://github.com/dmlc/xgboost/blob/f3df0d0eb455851248766818f0778783859a2ded/src/tree/hist/evaluate_splits.h#L201)), I understand that it is used to determine the begin oand end points of the double scan of the sorted histogram. Here is an example:

__Case with `max_cat_threshold` = 1__

In this case all partitions are considered.

```
| Forward | Backward |
|----------+----------|
| [BCDEF] A | F [ABCDE] |
| [CDEF] AB | EF [ABCD] |
| [DEF] ABC | DEF [ABC] |
| [EF] ABCD | CDEF [AB] |
| [F] ABCDE | BCDEF [A] |
```
__Case with `max_cat_threshold` = 2__

In this case only partitions with 2+ categories are considered.

```
| Forward | Backward |
|----------+----------|
| [CDEF] AB | EF [ABCD] |
| [DEF] ABC | DEF [ABC] |
| [EF] ABCD | CDEF [AB] |
```

Is this the way `max_cat_threshold`? If yes, I might open a PR to add a paragraph [here](https://xgboost.readthedocs.io/en/latest/tutorials/categorical.html#optimal-partitioning). Does it sound like a good idea?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.