min_data_in_leaf not working
- Dominant language
- C++
- Stars
- 9.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
Here's a minimal example, with CatBoost contrasted to XGBoost:
```python
from sklearn.datasets import load_diabetes
from catboost import CatBoostRegressor
import pandas as pd
from xgboost import XGBRegressor
X, y = load_diabetes(return_X_y=True)
model = CatBoostRegressor(
iterations=1,
min_data_in_leaf=100,
).fit(X, y)
train_leaf_indices = model.predict(X)
train_leaf_indices = pd.DataFrame(train_leaf_indices.ravel())
print("Catboost Predictions and counts")
print(train_leaf_indices.value_counts().sort_values(ascending=False))
model2 = XGBRegressor(
n_estimators=1,
min_child_weight=100,
).fit(X, y)
preds = model2.predict(X)
preds = pd.DataFrame(preds)
print("XGBoost Predictions and counts")
print(preds.value_counts().sort_values(ascending=False))
```
This sets both models to have exactly one tree and to have at least 100 samples in each leaf.
But when you look at examples you should see that catboost will have something like the below, where actually no leaf has the minimum required samples:
```
Catboost Predictions and counts
0
187.009170 63
130.140746 47
177.643830 45
122.592834 43
158.669186 38
123.072304 33
158.870454 24
159.783418 21
132.466752 20
124.076753 17
160.360506 13
145.675853 8
151.386765 7
141.477878 6
199.311211 6
160.533434 6
167.255656 6
148.404270 5
135.966770 5
149.452488 4
164.666774 4
130.166774 4
141.100113 3
...
160.491798 1
160.616798 1
171.366798 1
```
However XGBoost behaves as expected, where all leaves have at least 100 samples:
```
XGBoost Predictions and counts
0
144.459030 117
155.270706 116
174.054352 108
133.987946 101
```
Is this a misunderstanding on my part or a bug?
Contributor guide
Assessment
This issue has not been assessed yet.