You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on #3756 and #3867, as well as a variety of early-stopping related things (like #6424), I've found the heavy use of positional indexing and tuple unpacking in early stopping and related code make it really difficult to understand and modify.
I'm planning a series of PRs with the following types of changes:
unpacking tuples into named variables and using those named variables
introducing collections.namedtuple (docs) where appropriate to allow for named-attribute access while preserving backwards compatibility with the significant amount of custom code in the world relying on lightgbm expecting tuples for this like custom metrics:
Description
While working on #3756 and #3867, as well as a variety of early-stopping related things (like #6424), I've found the heavy use of positional indexing and tuple unpacking in early stopping and related code make it really difficult to understand and modify.
For example:
LightGBM/python-package/lightgbm/callback.py
Lines 167 to 176 in 53e0ddf
and:
LightGBM/python-package/lightgbm/callback.py
Lines 410 to 412 in 53e0ddf
I'm opening this issue to track some work I'd like to do to simplify that.
Benefits of this work
Reduces the effort required to finish these:
And to add finer-grained control over early stopping and validation, e.g.:
Approach
I'm planning a series of PRs with the following types of changes:
collections.namedtuple
(docs) where appropriate to allow for named-attribute access while preserving backwards compatibility with the significant amount of custom code in the world relying onlightgbm
expecting tuples for this like custom metrics:LightGBM/python-package/lightgbm/engine.py
Lines 135 to 138 in 53e0ddf
Notes
Looking at the current state of this code, it's important to remember that when the
lightgbm
Python package was first introduced 8+ years ago:dataclasses
was not in the standard library yet (that came in Python 3.7, first release in June 2018)The text was updated successfully, but these errors were encountered: