Lesson 36
CatBoost
Boost trees on tables that include categories, encoding each category from earlier rows so the current label does not leak.
Intermediate12 min
What You Will Learn
- Idea
- Example
- When to use it
Idea
CatBoost is gradient boosting that treats categories as categories. For a row, the category statistic is computed from earlier rows only, plus a prior. The current label never enters its own feature. Ordered boosting uses the same idea for the tree targets.
Example
cities = ["hyd", "hyd", "del", "hyd"]
labels = [1, 0, 1, 1]
earlier = [p for m, p in enumerate(labels) if cities[m] == "hyd" and m < 3]
print(f"earlier hyd labels: {earlier}")
print(f"ordered mean: {sum(earlier) / len(earlier):.2f}")Output:
earlier hyd labels: [1, 0]
ordered mean: 0.50When to use it
- Use it when category columns are a large part of the table.
- The ordered mean above is the encoding for the last hyd row, built without that row's label.
- It still needs a holdout. Ordered statistics reduce leakage. They do not replace a test set.
Loading playground…