@@ -47,3 +47,51 @@ def test_endtoend_hillclimbing():
4747 assert isinstance (best_params , dict ), "Best parameters should be a dictionary"
4848 assert "C" in best_params , "Best parameters should contain 'C'"
4949 assert "gamma" in best_params , "Best parameters should contain 'gamma'"
50+
51+
52+ def test_endtoend_lightgbm ():
53+ """Test end-to-end usage of HillClimbing optimizer with LightGBM experiment."""
54+ from skbase .utils .dependencies import _check_soft_dependencies
55+
56+ if not _check_soft_dependencies ("lightgbm" , severity = "none" ):
57+ return None
58+
59+ # 1. define the experiment
60+ from lightgbm import LGBMClassifier
61+ from sklearn .datasets import load_iris
62+
63+ from hyperactive .experiment .integrations import LightGBMExperiment
64+
65+ X , y = load_iris (return_X_y = True )
66+
67+ lgbm_exp = LightGBMExperiment (
68+ estimator = LGBMClassifier (n_estimators = 10 , verbosity = - 1 ),
69+ X = X ,
70+ y = y ,
71+ cv = 2 ,
72+ )
73+
74+ # 2. set up the HillClimbing optimizer
75+ import numpy as np
76+
77+ from hyperactive .opt import HillClimbing
78+
79+ hillclimbing_config = {
80+ "search_space" : {
81+ "n_estimators" : np .array ([5 , 10 , 20 ]),
82+ "max_depth" : np .array ([2 , 3 , 5 ]),
83+ },
84+ "n_iter" : 10 ,
85+ }
86+ hill_climbing = HillClimbing (** hillclimbing_config , experiment = lgbm_exp )
87+
88+ # 3. run the HillClimbing optimizer
89+ hill_climbing .solve ()
90+
91+ best_params = hill_climbing .best_params_
92+ assert best_params is not None , "Best parameters should not be None"
93+ assert isinstance (best_params , dict ), "Best parameters should be a dictionary"
94+ assert (
95+ "n_estimators" in best_params
96+ ), "Best parameters should contain 'n_estimators'"
97+ assert "max_depth" in best_params , "Best parameters should contain 'max_depth'"
0 commit comments