]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(quickadapter): use trial pruning for CatBoost grow_policy validation
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 8 Jan 2026 21:28:41 +0000 (22:28 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 8 Jan 2026 21:28:41 +0000 (22:28 +0100)
Replace dynamic grow_policy options with trial pruning to avoid Optuna's
"CategoricalDistribution does not support dynamic value space" error.

Always suggest all grow_policy options, but prune trials with incompatible
Ordered boosting + nonsymmetric trees combinations.

quickadapter/user_data/strategies/Utils.py

index 8cde3cc0eeb3d3004ae6b9d5f48b38dfde260b75..a2d4354eb962afd433253aa26ee59947e6e04482 100644 (file)
@@ -2489,10 +2489,13 @@ def get_optuna_study_model_parameters(
             "boosting_type", boosting_type_options
         )
         bootstrap_type = trial.suggest_categorical("bootstrap_type", bootstrap_options)
-        if boosting_type == "Ordered":
-            grow_policy_options = ["SymmetricTree"]
-        else:
-            grow_policy_options = ["SymmetricTree", "Depthwise", "Lossguide"]
+        grow_policy = trial.suggest_categorical(
+            "grow_policy", ["SymmetricTree", "Depthwise", "Lossguide"]
+        )
+        if boosting_type == "Ordered" and grow_policy != "SymmetricTree":
+            raise optuna.TrialPruned(
+                "Ordered boosting is not supported for nonsymmetric trees"
+            )
 
         params: dict[str, Any] = {
             # Boosting/Training
@@ -2513,9 +2516,7 @@ def get_optuna_study_model_parameters(
             "min_data_in_leaf": _optuna_suggest_int_from_range(
                 trial, "min_data_in_leaf", ranges["min_data_in_leaf"], min_val=1
             ),
-            "grow_policy": trial.suggest_categorical(
-                "grow_policy", grow_policy_options
-            ),
+            "grow_policy": grow_policy,
             # Regularization
             "l2_leaf_reg": trial.suggest_float(
                 "l2_leaf_reg",