dmlc / dmlc/xgboost

`booster.predict(..., pred_leaf = True)` way slower than other flags.

Open
#9,725 9 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

Why is predicting the leaf **way** slower than actual predicting? Doesn't xgboost have to get the leaf anyway for the predicted value?

```python
X, y = make_regression(n_samples = 100000, n_features = 10)
dmatrix = xgb.DMatrix(X, label = y)

model = xgb.XGBRegressor(n_estimators = 20, max_depth = 6)
model.fit(X, y)
booster = model.get_booster()

%%timeit
booster.predict(dmatrix, pred_leaf = True)
# 22.9 ms ± 626 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

%%timeit
booster.predict(dmatrix)
# 385 µs ± 26 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
```

(Isolating a single booster produces similar results)

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.