Skip to main content

LightGBM Callbacks

CI Status Documentation Status Test coverage percentage

uv Ruff prek

PyPI Version Supported Python versions License


Documentation: https://lightgbm-callbacks.readthedocs.io

Source Code: https://github.com/34j/lightgbm-callbacks


A collection of LightGBM callbacks. Provides implementations of ProgressBarCallback (#5867) and DartEarlyStoppingCallback (#4805), as well as an LGBMDartEarlyStoppingEstimator that automatically passes these callbacks. (#3313, #5808)

Installation

Install this via pip (or your favourite package manager):

pip install lightgbm-callbacks

Usage

SciKit-Learn API, simple

from lightgbm import LGBMRegressor
from lightgbm_callbacks import LGBMDartEarlyStoppingEstimator
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split

X, y = load_diabetes(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y)
LGBMDartEarlyStoppingEstimator(
    LGBMRegressor(boosting_type="dart"), # or "gbdt", ...
    stopping_rounds=10, # or n_iter_no_change=10
    test_size=0.2, # or validation_fraction=0.2
    shuffle=False,
    tqdm_cls="rich", # "auto", "autonotebook", ...
).fit(X_train, y_train)

Scikit-Learn API, manually passing callbacks

from lightgbm import LGBMRegressor
from lightgbm_callbacks import ProgressBarCallback, DartEarlyStoppingCallback
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split

X, y = load_diabetes(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y)
X_train, X_val, y_train, y_val = train_test_split(X_train, y_train)
early_stopping_callback = DartEarlyStoppingCallback(stopping_rounds=10)
LGBMRegressor(
).fit(
    X_train,
    y_train,
    eval_set=[(X_train, y_train), (X_val, y_val)],
    callbacks=[
        early_stopping_callback,
        ProgressBarCallback(early_stopping_callback=early_stopping_callback),
    ],
)

Details on DartEarlyStoppingCallback

Below is a description of the DartEarlyStoppingCallback method parameter and lgb.plot_metric for each lgb.LGBMRegressor(boosting_type="dart", n_estimators=1000) trained with entire sklearn_datasets.load_diabetes() dataset.

Method Description iteration Image Actual iteration
(Baseline) If Early stopping is not used. n_estimators image 1000
"none" Do nothing and return the original estimator. min(best_iteration + early_stopping_rounds, n_estimators) image 50
"save" Save the best model by deepcopying the estimator and return the best model (using pickle). min(best_iteration + 1, n_estimators) image 21
"refit" Refit the estimator with the best iteration and return the refitted estimator. min(best_iteration, n_estimators) image 20

Metadata

Release files for lightgbm-callbacks 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lightgbm-callbacks 1.0.0
File Size Uploaded Provenance Actions
lightgbm_callbacks-1.0.0.tar.gz 15.3 kB With provenance Details for lightgbm_callbacks-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lightgbm-callbacks 1.0.0
File Interpreter ABI Platform Actions
lightgbm_callbacks-1.0.0-py3-none-any.whl Python 3 none any Details for lightgbm_callbacks-1.0.0-py3-none-any.whl

Total release size: 30.4 kB

Release files / lightgbm_callbacks-1.0.0.tar.gz

Download URL lightgbm_callbacks-1.0.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ebb9b16ef1037844208eb24c22fae82bf404062d052092feb0d4397bbc2ab824
BLAKE2b-256 checksum
How to use checksums
a12e7786b3e019cd24e89bc04fcb7e3c08464a52b07ca39f3b979f0d9bc8339d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / lightgbm_callbacks-1.0.0-py3-none-any.whl

Download URL lightgbm_callbacks-1.0.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46b461ea7711e3a87512e55fdd87f557479b822285588982890fd2aae7a0c56c
BLAKE2b-256 checksum
How to use checksums
a4468bfb82d03cd3e8894cc04ec3daed489deed1c5dbcccc830dad26b3d3cc3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for lightgbm-callbacks 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lightgbm_callbacks-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page