Repository navigation
feat: expose LightGBM importance type - #1177
Open
divya234-hue wants to merge 1 commit into
Open
divya234-hue wants to merge 1 commit into
divya234-hue wants to merge 1 commit into
Conversation
Author
|
Hi! Could a maintainer please approve the workflows so the checks can run? Thanks! |
bartpleiter
requested changes
Nov 12, 2026
bartpleiter
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for your contribution! The changes look great and are approved, only a minor styling inconsistency with the tests that I would like to see fixed before we merge it.
Comment on lines
+43
to
+57
| def test_lgbm_forecaster__importance_type_is_passed_to_models(importance_type: Literal["split", "gain"]) -> None: | ||
| forecaster = LGBMForecaster( | ||
| quantiles=[Q(0.1), Q(0.5), Q(0.9)], | ||
| horizons=[LeadTime(timedelta(days=1))], | ||
| hyperparams=LGBMHyperParams(importance_type=importance_type), | ||
| ) | ||
|
|
||
| assert all(model.get_params()["importance_type"] == importance_type for model in forecaster._lgbm_model.models) | ||
|
|
||
|
|
||
| def test_lgbm_forecaster__importance_type_defaults_to_split(base_config: LGBMForecaster) -> None: | ||
| assert base_config.hyperparams.importance_type == "split" | ||
| assert all(model.get_params()["importance_type"] == "split" for model in base_config._lgbm_model.models) | ||
|
|
||
|
|
Collaborator
There was a problem hiding this comment.
Tests look good, but as a minor nitpick it would be great if you could add the arrange act assert comments like in the other tests for consistency.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
LightGBM feature importance is currently calculated using its default
splitmethod, with no way to choose the alternativegainmethod through OpenSTEF. This adds a typedimportance_typeoption toLGBMHyperParams, keeps the existingsplitdefault, and passes the selected value to each quantile estimator. Supported options aresplitandgain.Closes #1170
Type of change
Breaking changes checklist
_migrate_statemigration patternMigration path for existing users (e.g. "old pickled
XScalerobjects auto-migrate on load", "users must now passXexplicitly"):N/A. The new configuration field is additive and defaults to LightGBM's existing
splitbehavior.AI disclosure
Assisted-by: <tool name>)AI assistance is disclosed here. The current commit does not include an
Assisted-bytrailer; the code and tests were validated as listed below.Checklist
poe all --checkpasses locallygit commit -s)feat: ...,fix: ...,feat!: ...for breaking changes)Targeted checks passed:
uv run pytest packages\openstef-models\tests\unit\models\forecasting\test_lgbm_forecaster.py -q(9 passed)uv run ruff check packages\openstef-models\src\openstef_models\models\forecasting\lgbm_forecaster.py packages\openstef-models\tests\unit\models\forecasting\test_lgbm_forecaster.py(passed)uv run ruff format --check packages\openstef-models\src\openstef_models\models\forecasting\lgbm_forecaster.py packages\openstef-models\tests\unit\models\forecasting\test_lgbm_forecaster.py(passed)uv run ty check packages\openstef-models\src\openstef_models\models\forecasting\lgbm_forecaster.py packages\openstef-models\tests\unit\models\forecasting\test_lgbm_forecaster.py(passed)git diff --check(passed)The full
poe all --checksuite was not run. The current commit is not DCO-signed-off.