{"id":15288214,"url":"https://github.com/34j/boost-loss","last_synced_at":"2025-10-08T23:21:35.899Z","repository":{"id":167878468,"uuid":"643412040","full_name":"34j/boost-loss","owner":"34j","description":"Utilities for easy use of custom losses in CatBoost, LightGBM, XGBoost.","archived":false,"fork":false,"pushed_at":"2025-08-04T17:05:44.000Z","size":498,"stargazers_count":9,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-04T20:36:37.910Z","etag":null,"topics":["autograd","catboost","custom-loss","custom-loss-functions","evaluation-metrics","gbdt","gradient-boosting","hacktoberfest","lightgbm","pytorch","scikit-learn","sklearn","sklearn-compatible","xgboost"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/34j.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["34j"]}},"created_at":"2023-05-21T04:30:31.000Z","updated_at":"2025-02-07T14:50:25.000Z","dependencies_parsed_at":"2023-09-23T14:52:07.396Z","dependency_job_id":"dec62395-9d99-410a-a697-39a6988542d2","html_url":"https://github.com/34j/boost-loss","commit_stats":{"total_commits":150,"total_committers":4,"mean_commits":37.5,"dds":"0.22666666666666668","last_synced_commit":"079054eac075fbfbb42e637af4ee671978b713da"},"previous_names":["34j/boost-loss"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/34j/boost-loss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Fboost-loss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Fboost-loss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Fboost-loss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Fboost-loss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/34j","download_url":"https://codeload.github.com/34j/boost-loss/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Fboost-loss/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269969457,"owners_count":24505429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autograd","catboost","custom-loss","custom-loss-functions","evaluation-metrics","gbdt","gradient-boosting","hacktoberfest","lightgbm","pytorch","scikit-learn","sklearn","sklearn-compatible","xgboost"],"created_at":"2024-09-30T15:44:46.045Z","updated_at":"2025-10-08T23:21:30.864Z","avatar_url":"https://github.com/34j.png","language":"Python","funding_links":["https://github.com/sponsors/34j"],"categories":[],"sub_categories":[],"readme":"# Boost Loss\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/34j/boost-loss/actions/workflows/ci.yml?query=branch%3Amain\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/34j/boost-loss/ci.yml?branch=main\u0026label=CI\u0026logo=github\u0026style=flat-square\" alt=\"CI Status\" \u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://boost-loss.readthedocs.io\"\u003e\n    \u003cimg src=\"https://img.shields.io/readthedocs/boost-loss.svg?logo=read-the-docs\u0026logoColor=fff\u0026style=flat-square\" alt=\"Documentation Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/34j/boost-loss\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/34j/boost-loss.svg?logo=codecov\u0026logoColor=fff\u0026style=flat-square\" alt=\"Test coverage percentage\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://python-poetry.org/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=\" alt=\"Poetry\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/ambv/black\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square\" alt=\"black\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/pre-commit/pre-commit\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white\u0026style=flat-square\" alt=\"pre-commit\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/boost-loss/\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/boost-loss.svg?logo=python\u0026logoColor=fff\u0026style=flat-square\" alt=\"PyPI Version\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/pypi/pyversions/boost-loss.svg?style=flat-square\u0026logo=python\u0026amp;logoColor=fff\" alt=\"Supported Python versions\"\u003e\n  \u003cimg src=\"https://img.shields.io/pypi/l/boost-loss.svg?style=flat-square\" alt=\"License\"\u003e\n\u003c/p\u003e\n\nUtilities for easy use of custom losses in CatBoost, LightGBM, XGBoost. This sounds very simple, but in reality it took a lot of work.\n\n## Installation\n\nInstall this via pip (or your favourite package manager):\n\n```shell\npip install boost-loss\n```\n\n## Usage\n\n### Basic Usage\n\n```python\nimport numpy as np\n\nfrom boost_loss import LossBase\nfrom numpy.typing import NDArray\n\n\nclass L2Loss(LossBase):\n    def loss(self, y_true: NDArray, y_pred: NDArray) -\u003e NDArray:\n        return (y_true - y_pred) ** 2 / 2\n\n    def grad(self, y_true: NDArray, y_pred: NDArray) -\u003e NDArray: # dL/dy_pred\n        return - (y_true - y_pred)\n\n    def hess(self, y_true: NDArray, y_pred: NDArray) -\u003e NDArray: # d^2L/dy_pred^2\n        return np.ones_like(y_true)\n```\n\n```python\nimport lightgbm as lgb\n\nfrom boost_loss import apply_custom_loss\nfrom sklearn.datasets import load_boston\n\n\nX, y = load_boston(return_X_y=True)\napply_custom_loss(lgb.LGBMRegressor(), L2Loss()).fit(X, y)\n```\n\nBuilt-in losses are available. [^bokbokbok]\n\n```python\nfrom boost_loss.regression import LogCoshLoss\n```\n\n### [`torch.autograd`](https://pytorch.org/docs/stable/autograd.html) Loss [^autograd]\n\n```python\nimport torch\n\nfrom boost_loss.torch import TorchLossBase\n\n\nclass L2LossTorch(TorchLossBase):\n    def loss_torch(self, y_true: torch.Tensor, y_pred: torch.Tensor) -\u003e torch.Tensor:\n        return (y_true - y_pred) ** 2 / 2\n```\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/34j\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/55338215?v=4?s=80\" width=\"80px;\" alt=\"34j\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003e34j\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/34j/boost-loss/commits?author=34j\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#ideas-34j\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/34j/boost-loss/commits?author=34j\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n[^bokbokbok]: Inspired by [orchardbirds/bokbokbok](https://github.com/orchardbirds/bokbokbok)\n[^autograd]: Inspired by [TomerRonen34/treeboost_autograd](https://github.com/TomerRonen34/treeboost_autograd)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F34j%2Fboost-loss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F34j%2Fboost-loss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F34j%2Fboost-loss/lists"}