treeboost_autograd
Easy Custom Losses for Tree Boosters using Pytorch
Why calculate first and second derivatives for your objective when you can let PyTorch do it for you?
This packages includes an easy to use custom PyTorch objective implementation for tree boosters (just add loss).
Supported boosting packages: CatBoost, XGBoost, LightGBM.
Supported tasks: regression, binary classification.
Check out the post in Towards Data Science: https://towardsdatascience.com/easy-custom-losses-for-tree-boosters-using-pytorch-57ffaa0b2eb3
Usage
Usage is very similar for all boosting libraries:
from treeboost_autograd import CatboostObjective, LightGbmObjective, XgboostObjective
Ready-to-run examples are available at the Git repo: https://github.com/TomerRonen34/treeboost_autograd/tree/main/examples
pip install treeboost_autograd
def absolute_error_loss(preds: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:
return torch.abs(preds - targets).sum()
custom_objective = CatboostObjective(loss_function=absolute_error_loss)
model = CatBoostRegressor(loss_function=custom_objective, eval_metric="MAE")
model.fit(X_train, y_train)
Metadata
Release files for treeboost_autograd 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| treeboost_autograd-0.1.2.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| treeboost_autograd-0.1.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 12.5 kB
Release files / treeboost_autograd-0.1.2.tar.gz
| Download URL | treeboost_autograd-0.1.2.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f22e0b6a367732c256648817c4ee1cf7e00b3da8442e09b2adbef6ece183b08
|
|
BLAKE2b-256 checksum How to use checksums |
8fead996c432a4042065bded4b826609ebe71f8a4ee1f1a079b7019de2fe2087
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.21.0
|
Release files / treeboost_autograd-0.1.2-py2.py3-none-any.whl
| Download URL | treeboost_autograd-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f3862331d2bd441b4b0c621231a660e9fac1ef04a92bed1bba18068004c27454
|
|
BLAKE2b-256 checksum How to use checksums |
618b80cbe09bd03ac1579770017447da78cfe1f72578190996ca61670a05ebbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.21.0
|