From dbe2be24cc33f281c271aa36be3ebcbb0c0d8a56 Mon Sep 17 00:00:00 2001 From: kajal-jotwani Date: Fri, 20 Feb 2026 22:13:24 +0530 Subject: [PATCH] Add LightGBM Experiment integration --- .../experiment/integrations/__init__.py | 2 + .../integrations/lightgbm_experiment.py | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/hyperactive/experiment/integrations/lightgbm_experiment.py diff --git a/src/hyperactive/experiment/integrations/__init__.py b/src/hyperactive/experiment/integrations/__init__.py index c302e25a..351d97f5 100644 --- a/src/hyperactive/experiment/integrations/__init__.py +++ b/src/hyperactive/experiment/integrations/__init__.py @@ -2,6 +2,7 @@ # copyright: hyperactive developers, MIT License (see LICENSE file) from hyperactive.experiment.integrations.sklearn_cv import SklearnCvExperiment +from hyperactive.experiment.integrations.lightgbm_experiment import LightGBMExperiment from hyperactive.experiment.integrations.skpro_probareg import ( SkproProbaRegExperiment, ) @@ -21,4 +22,5 @@ "SktimeClassificationExperiment", "SktimeForecastingExperiment", "TorchExperiment", + "LightGBMExperiment", ] diff --git a/src/hyperactive/experiment/integrations/lightgbm_experiment.py b/src/hyperactive/experiment/integrations/lightgbm_experiment.py new file mode 100644 index 00000000..bfc551a9 --- /dev/null +++ b/src/hyperactive/experiment/integrations/lightgbm_experiment.py @@ -0,0 +1,64 @@ +"""Experiment adapter for LightGBM cross-validation experiments.""" + +# copyright: hyperactive developers, MIT License (see LICENSE file) + +from hyperactive.experiment.integrations.sklearn_cv import SklearnCvExperiment + + +class LightGBMExperiment(SklearnCvExperiment): + """Experiment adapter for LightGBM cross-validation experiments. + + Thin wrapper around SklearnCvExperiment for LightGBM estimators. + + LightGBM estimators follow the sklearn API, so this class does not + add new functionality beyond SklearnCvExperiment. It exists for + discoverability and explicit LightGBM support. + """ + + _tags = { + "python_dependencies": "lightgbm", + } + + @classmethod + def get_test_params(cls, parameter_set="default"): + """Return testing parameter settings for the estimator.""" + from skbase.utils.dependencies import _check_soft_dependencies + + if not _check_soft_dependencies("lightgbm", severity="none"): + return [] + + from sklearn.datasets import load_iris, load_diabetes + from lightgbm import LGBMClassifier, LGBMRegressor + + # Classification test case + X, y = load_iris(return_X_y=True) + params0 = { + "estimator": LGBMClassifier(n_estimators=10), + "X": X, + "y": y, + "cv": 2, + } + + # Regression test case + X, y = load_diabetes(return_X_y=True) + params1 = { + "estimator": LGBMRegressor(n_estimators=10), + "X": X, + "y": y, + "cv": 2, + } + + return [params0, params1] + + @classmethod + def _get_score_params(cls): + """Return parameter settings for score/evaluate tests.""" + from skbase.utils.dependencies import _check_soft_dependencies + + if not _check_soft_dependencies("lightgbm", severity="none"): + return [] + + val0 = {"n_estimators": 5, "max_depth": 2} + val1 = {"n_estimators": 5, "max_depth": 2} + + return [val0, val1] \ No newline at end of file