Commit Graph

986 Commits

Author SHA1 Message Date
James Lamb ac8d3afd2a [python-package] eagerly construct Dataset in scikit-learn fit() 2026-05-22 22:37:49 -05:00
James Lamb a3734ed272 [python-package] publish nightlies to pypi.anaconda.org (#7245) 2026-05-17 05:30:14 +00:00
James Lamb eda8bdccf2 [ci] [R-package] fix docs build, test pkgdown build in CI (#7268)
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-05-17 03:53:03 +08:00
Oliver Borchert 8490fde16a [python-package] Add official support for Python 3.14 (#7279)
* [python-package] Add official support for Python 3.14

* Fix lint

* Update .github/workflows/python_package.yml
2026-05-16 18:59:52 +00:00
Oliver Borchert d452cf8409 [python-package] Bump minimum pyarrow version to v16.0.0 (#7280)
* [python-package] Bump minimum pyarrow version to v16.0.0

* snappy
2026-05-17 01:27:47 +08:00
Oliver Borchert 634c864bc7 [python-package] Enable ruff rule B905 (#7278)
* [python-package] Enable ruff rule `B905`

* Use strict true

* Fix

* Fix

* Fix test
2026-05-16 10:57:01 +00:00
Oliver Borchert fe2673720a [python-package] Bump minimum supported Python version to 3.10 (#7276) 2026-05-15 10:15:04 -05:00
Oliver Borchert cf4121dd75 [python-package] Bump minimum pyarrow dependency version to v14.0.2 (#7277) 2026-05-14 19:26:44 -05:00
Arjun Prakash 2ccb9fd104 [python-package] fix misleading redundant parameter warnings in Booster.refit() (#7124)
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-04-23 09:55:01 -05:00
James Lamb 4472f3901e [ci] adapt to scikit-learn ClassifierChain changes, fix {fs} install, work around pyarrow type-checking issues (#7236) 2026-04-22 23:13:23 -05:00
James Lamb a7d00a9611 [python-package] standardize variable naming for evaluation results (#7163) 2026-04-01 11:38:47 -05:00
CoderWota 180e35c47d [python-package] Add decision_function() to LGBMClassifier (#7159)
Co-authored-by: Wota <wota@wota.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-03-31 23:10:01 -05:00
James Lamb 1d878207fc [docs] [ci] Update docs and source code for org change (#7188)
* update organization reference, copyrights

* add note about the repo change

* make all GPU CI manual-only
2026-03-11 07:02:01 -05:00
Juan Flores 55a26969b7 [python-package] plot_importance(): raise clearer exception when model has 0 splits (#7160)
* [python-package] fix plot_importance() crash when model has 0 splits

* address review: use load_breast_cancer + min_data_in_bin

---------

Co-authored-by: Juan Flores <juanf-0gravity@users.noreply.github.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-03-01 14:17:55 -06:00
James Lamb fb973c0ecf [python-package] [dask] [ci] fix predict() type hints, enforce mypy in CI (#7140) 2026-02-12 21:11:04 -06:00
James Lamb 6af94aadf3 [python-package] use PEP 639 license metadata, bump toscikit-build-core>=0.11.0, use hatchling instead of setuptools (#7135) 2026-01-21 08:59:22 -06:00
Austin Wagner 56be785e0d [python-package] cast numpy integer to float in plot_importance ax.text call (#7130)
The y-coordinate passed to matplotlib's ax.text() was a numpy signedinteger from
np.arange(), but matplotlib's type stubs expect a Python float. This cast follows
the existing pattern in engine.py where float() is used to convert numpy values.

Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-01-19 17:30:24 +03:00
Christian Lorentzen bfa2951e32 [python-package] scikit-learn fit() methods: add eval_X, eval_y, deprecate eval_set (#6857)
* ENH add eval_X, eval_y, deprecate eval_set

* CLN eval_X, eval_y in all fit signatures

* ENH eval_X and eval_y in _DaskLGBMModel

* CLN appease ruff/linting

* FIX _validate_eval_set_Xy

* FIX dask

* MNT make eval_X and eval_y keyword only

* TST add test_eval_set_raises

* MNT apply review suggestion for test_eval_X_eval_y_eval_set_equivalence

* MNT make eval_X and eval_y keyword only also for Dask backend

* CLN remove whitespace

* MNT remove docstring modification of eval_sample_weight

* update examples, handle eval_group validation in LGBMRanker, make tests stricter

* Apply suggestions from code review

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>

* Update tests/python_package_test/test_sklearn.py

Co-authored-by: James Lamb <jaylamb20@gmail.com>

* Update python-package/lightgbm/sklearn.py

* use version-deprecated, fix formatting

* use .. deprecated

* keyword-only arguments

* fix docs indentation

---------

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-01-19 17:24:07 +03:00
James Lamb 8b5ebccba7 [python-package] enforce keyword-only args in more internal functions (#7111)
* [python-package] enforce keyword-only args in more internal functions

* keyword-only args for more early-stopping arguments
2026-01-19 17:12:09 +03:00
James Lamb c70d8aab81 [python-package] support all-0 sample weights in scikit-learn 1.9 (#7128) 2026-01-17 19:43:14 -06:00
Austin Wagner cd7898c3eb [python-package] Add return type annotations to predict methods in sklearn module (#7116)
* [python-package] Add return type annotations to predict methods in sklearn module

Add return type annotations to LGBMModel.predict, LGBMClassifier.predict, and LGBMClassifier.predict_proba methods. The predict_proba method requires an isinstance assertion for type narrowing in the binary classification branch, since predict() returns a union type but only returns np.ndarray when pred_contrib=False. This follows the existing error message pattern used in _get_label_from_constructed_dataset and similar helper functions.

Fixes: https://github.com/microsoft/LightGBM/issues/3867

* [python-package] Add shared _LGBM_PredictReturnType type alias for predict methods

Add _LGBM_PredictReturnType type alias in basic.py and use it in _InnerPredictor.predict(),
Booster.predict(), LGBMModel.predict(), LGBMClassifier.predict(), and LGBMClassifier.predict_proba().

Also add assert isinstance() with error message in predict_proba() for type narrowing when
returning binary classification results.

This keeps the return type DRY and ensures consistency across the codebase.

* Update python-package/lightgbm/basic.py

---------

Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-01-17 17:03:37 -06:00
Austin Wagner 33e93d602d [python-package] add Literal type annotation for order variable in _np2d_to_np1d (#7118)
* [python-package] add Literal type annotation for order variable in _np2d_to_np1d

The order variable was inferred as str but numpy.asarray expects Literal['K', 'A', 'C', 'F']. Added explicit Literal["C", "F"] type annotation before the conditional assignment. This resolves the mypy call-overload error for np.asarray at line 201.
2026-01-06 07:55:31 -06:00
Austin Wagner 1456356dc7 [python-package] Add DTypeLike annotation to fix dtype assignment in _np2d_to_np1d (#7117)
[python-package] Add DTypeLike annotation to fix dtype assignment type in _np2d_to_np1d

Add type annotation for dtype variable to resolve mypy assignment error.
This follows the existing pattern used elsewhere in basic.py (lines 337, 364, 463, 800, 2795).

Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-01-06 07:49:02 -06:00
Austin Wagner c99526f548 [python-package] use positional args for np.arange in _InnerPredictor (#7119)
The numpy stubs define arange with positional-only parameters so keyword
arguments start=, stop=, step= do not match any overload. Changed to
positional arguments np.arange(_MAX_INT32, nrow, _MAX_INT32) which matches
the numpy stubs correctly and resolves the mypy call-overload errors.

Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-01-06 07:45:16 -06:00
Austin Wagner 96cc6723f7 [python-package] Add TypeGuard return type to _is_pyarrow_table() for mypy type narrowing (#7115)
Change _is_pyarrow_table() return type from bool to TypeGuard[pa_Table] to enable mypy type narrowing at all call sites. This follows the existing pattern used by _is_pyarrow_array() and allows mypy to recognize data.column_names as valid when extracting feature names from PyArrow tables.

Fixes: https://github.com/microsoft/LightGBM/issues/3867

Co-authored-by: James Lamb <jaylamb20@gmail.com>
2026-01-05 13:45:30 -06:00
James Lamb 52659d47a2 [ci] move GPU and NuGet jobs to GitHub Actions, remove Azure DevOps (#7106)
* [ci] move GPU and NuGet jobs to GitHub Actions, remove Azure DevOps

* try moving NuGet package over

* delete .vsts-ci

* fix aliases

* install mono

* sudo

* make upload-artifact stricter

* restore all CI

* Apply suggestions from code review

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>

* more updates

---------

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2025-12-21 16:24:21 -06:00
James Lamb 2e7e35e4f0 [python-package] fix mypy errors about __sklearn_tags__() (#7107) 2025-12-18 16:54:07 +03:00
Nikita Titov 32781bae00 [ci] move mypy to pre-commit (#7062) 2025-10-15 22:21:45 -05:00
Nikita Titov 6368375b62 [ci][docs] fix link checking action by switching from linkchecker to lychee and update some links (#7027) 2025-10-11 00:21:09 -05:00
Yusuke Horibe f981fba730 [python-package] add PyArrow Table to get_data (#6911)
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2025-09-12 18:42:31 -05:00
Oliver Borchert 0ffd2a3af4 [python-package] Fix mypy checks in engine.py (#6900)
* [python-package] Fix mypy checks in `engine.py`

* Update python-package/lightgbm/engine.py

---------

Co-authored-by: James Lamb <jaylamb20@gmail.com>
2025-08-27 03:21:38 +03:00
James Lamb 97ff708708 [ci] use 'pre-commit' to run 'rstcheck' (#6989)
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2025-08-12 21:15:23 -05:00
James Lamb ccc06d1902 [docs] [python-package] document how to run Python tests (#6995)
* [docs] [python-package] document how to run Python tests

* refer to installation instructions

---------

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2025-08-13 03:47:38 +03:00
James Lamb 16ca335b4a [ci] update pre-commit versions, add some pixi things to config files (#6986) 2025-08-03 22:01:25 -05:00
Oliver Borchert 915c2706aa [ci] Drop support for Python 3.7 and Python 3.8 (#6896)
* [ci] Drop support for Python 3.7 and Python 3.8

* Fix

* Bump numpy

* Fix

* fix comment, revert unrelated quoting changes

* add docs

---------

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2025-07-30 01:43:57 +03:00
Oliver Borchert 2a5e33b79d [python-package] Fix mypy checks in compat.py (#6898)
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2025-07-28 22:22:01 -05:00
gmhewett c73a21b301 [python-package] Follow symlinks to lib_lightgbm.so in library-loading (#6977) 2025-07-28 20:14:08 -05:00
Nick Miller 0ec55c97c3 [ci][python-package] Enforce and fix ruff flake8-pytest-style (PT) linting codes (#6959)
* Add "PT" ruff code to pyproject.toml plus some exceptions

* Extend PT011 for Exception, IndexError, TypeError

* Fix PT001: Use `@pytest.fixture` over `@pytest.fixture()`

* Fix PT011: pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception

* Fix PT012: `pytest.raises()` block should contain a single simple statement

* Fix PT017: Found assertion on exception {name} in except block, use pytest.raises() instead

* Fix PT018: Assertion should be broken down into multiple parts

* Remove PT006 and PT007 from ignore list and fixup

* Use *Exception and *Error glob to apply PT011 and ignore AssertionErrors

---------

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2025-07-14 22:54:39 +03:00
Malte Londschien 54f481ef77 [docs] Fix docs of Booster.update's return value is_finished (#6890)
* Update docs.

* that is

* Implement suggestions

* Update python-package/lightgbm/basic.py

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>

---------

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2025-07-14 20:51:43 +03:00
Nikita Titov 72a39817c3 [python-package][sklearn] Support PyArrow Table as an input in scikit-learn methods (#6910) 2025-05-26 21:07:46 -05:00
Nikita Titov f91dcfee8b [docs][python] update types in docstring (#6897)
* Update basic.py

* Update sklearn.py

* Update basic.py

* Update basic.py

* Update basic.py

* Update basic.py

* Update basic.py

* Update basic.py

* Update basic.py

* Update basic.py

* Update basic.py

* Update sklearn.py

* Update sklearn.py

* Update sklearn.py
2025-05-03 04:58:14 +03:00
Yusuke Horibe 9111ade725 [python-package] Add superfluous-else-raise (RET506) rule to Ruff (#6904)
* [python-package] Add superfluous-else-raise rule to ruff lint configuration

* [python-package] Fix code to follow superfluous-else-raise rule

* [python-package] Move RET506 after RET504 to maintain alphabetical order and add source rule set comment

* [python-package] Revert unintended change to preserve original formatting
2025-04-29 05:47:11 +03:00
James Lamb ec5492f8f9 [python-package] drop support for h2o datatable (#6894) 2025-04-27 17:59:32 +03:00
Joaquín Ignacio Aramendía 06e94adadd [python-package] Load parameters from model string (#6852)
* [python-package] Test serialization and deserialization from in-memory string

Test case for #6851

* [python-package] Fill in `params` when loading from in-memory string

This fixes #6851 by using the same workaround as when loading the model
from a file.

* test_basic: use rng instead of legacy numpy RandomState

* test_basic: remove debug prints leftovers

Co-authored-by: James Lamb <jaylamb20@gmail.com>

* test_basic: add boolean, array of float and array of integers to testcase

Co-authored-by: James Lamb <jaylamb20@gmail.com>

* test_basic: make a cheaper model (2 rounds with 7 leaves each)

Co-authored-by: James Lamb <jaylamb20@gmail.com>

* test_basic: bugfix typos

* python_package_test: move string load test from basic to engine

* test_engine: catch params ignored warnings

* test_engine: be explicit about parameters assertion

* test_engine: shush linter complaint

* test_basic: delete empty line

Co-authored-by: James Lamb <jaylamb20@gmail.com>

* test_engine: even cheaper model with less features

Co-authored-by: James Lamb <jaylamb20@gmail.com>

* test_engine: delete redundant assert

Co-authored-by: James Lamb <jaylamb20@gmail.com>

* test_engine: run pre-commit and take it's word for it

* test_engine: be explicit in an E712 compliant way

* test_engine.py: pass different value as argument to make sure it is ignored

---------

Co-authored-by: James Lamb <jaylamb20@gmail.com>
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2025-04-24 19:31:48 +03:00
James Lamb ac24188808 [python-package] enforce keyword args in internal functions (#6858)
* [python-package] enforce keyword args in internal functions

* fix

* fixes

* empty commit
2025-04-24 12:18:11 +03:00
Nikita Titov d18fff10a4 [docs] update Python-package installation guide (#6767)
* Update README.rst

* Update README.rst

* Update pyproject.toml

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update pyproject.toml

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update pyproject.toml

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update pyproject.toml

* Update README.rst

* Update README.rst

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update README.rst

* Update README.rst

* Update build-python.sh

* Update README.rst

* Update README.rst

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update README.rst

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update README.rst

* Update build-python.sh

* Update README.rst

* Update README.rst

* Update README.rst

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update build-python.sh

* Update LightGBM.vcxproj

* Update LightGBM.vcxproj

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* no more than one sentence per one line

* address review comments

* address review comments

---------

Co-authored-by: James Lamb <jaylamb20@gmail.com>
2025-04-17 12:39:29 +03:00
James Lamb 5aaaec8e8b [ci] [python-package] re-enable scikit-build-core binary stripping (#6872) 2025-04-17 00:40:55 -05:00
James Lamb 6437645c4a [docs] add a note about DART in early_stopping docstring (#6846)
* [python-package] add a note about DART in early_stopping docstring

* add note in R docs too
2025-03-04 19:57:39 +03:00
James Lamb 604e2c5e83 bump development version to v4.6.0.99 (#6826)
* bump development version to v4.6.0.99

* Auto-update configure

* Update python-package/pyproject.toml

---------

Co-authored-by: GitHub Actions Bot <githubactionsbot@users.noreply.github.com>
2025-02-16 22:20:36 +03:00
James Lamb d02a01ac6f release v4.6.0 (#6796)
Co-authored-by: shiyu1994 <shiyu_k1994@qq.com>
Co-authored-by: GitHub Actions Bot <githubactionsbot@users.noreply.github.com>
2025-02-14 14:27:28 -06:00