From 3b8f1eeb2dbc28d33f3cdd788e5bee536012a8f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 28 Dec 2025 20:42:58 +0100 Subject: [PATCH] perf(quickadapter): refine optuna hyperparameters search space MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../freqaimodels/QuickAdapterRegressorV3.py | 2 +- .../user_data/strategies/QuickAdapterV3.py | 2 +- quickadapter/user_data/strategies/Utils.py | 29 ++++++++++++------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index e81c955..187ecd4 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -72,7 +72,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): https://github.com/sponsors/robcaulk """ - version = "3.8.0" + version = "3.8.1" _TEST_SIZE: Final[float] = 0.1 diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 2359bf4..090b5be 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -106,7 +106,7 @@ class QuickAdapterV3(IStrategy): _TRADING_MODES: Final[tuple[TradingMode, ...]] = ("spot", "margin", "futures") def version(self) -> str: - return "3.8.0" + return "3.8.1" timeframe = "5m" diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 98881ad..b0a1307 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -2185,6 +2185,8 @@ def get_optuna_study_model_parameters( "reg_alpha": (1e-8, 10.0), "reg_lambda": (1e-8, 10.0), "gamma": (1e-8, 1.0), + # Binning + "max_bin": (63, 255), } log_scaled_params = { "n_estimators", @@ -2201,11 +2203,6 @@ def get_optuna_study_model_parameters( grow_policy = trial.suggest_categorical( "grow_policy", ["depthwise", "lossguide"] ) - tree_method = ( - "hist" - if grow_policy == "lossguide" - else trial.suggest_categorical("tree_method", ["hist", "approx"]) - ) return { # Boosting/Training @@ -2219,7 +2216,6 @@ def get_optuna_study_model_parameters( log=True, ), # Tree structure - "tree_method": tree_method, "grow_policy": grow_policy, **( { @@ -2271,6 +2267,10 @@ def get_optuna_study_model_parameters( "gamma": trial.suggest_float( "gamma", ranges["gamma"][0], ranges["gamma"][1], log=True ), + # Binning + "max_bin": _optuna_suggest_int_from_range( + trial, "max_bin", ranges["max_bin"], min_val=2 + ), } elif regressor == REGRESSORS[1]: # "lightgbm" @@ -2408,6 +2408,17 @@ def get_optuna_study_model_parameters( log=True, ) + max_depth = trial.suggest_categorical( + "max_depth", [None, 2, 3, 4, 5, 6, 7, 8, 10, 12, 15] + ) + + max_leaf_nodes_range = ranges["max_leaf_nodes"] + if isinstance(max_depth, int) and max_depth > 0: + max_leaf_nodes_range = ( + max_leaf_nodes_range[0], + min(max_leaf_nodes_range[1], float(2**max_depth)), + ) + return { # Boosting/Training "max_iter": _optuna_suggest_int_from_range( @@ -2420,11 +2431,9 @@ def get_optuna_study_model_parameters( log=True, ), # Tree structure - "max_depth": trial.suggest_categorical( - "max_depth", [None, 2, 3, 4, 5, 6, 7, 8, 10, 12, 15] - ), + "max_depth": max_depth, "max_leaf_nodes": _optuna_suggest_int_from_range( - trial, "max_leaf_nodes", ranges["max_leaf_nodes"], min_val=2, log=True + trial, "max_leaf_nodes", max_leaf_nodes_range, min_val=2, log=True ), # Leaf constraints "min_samples_leaf": _optuna_suggest_int_from_range( -- 2.53.0