]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(quickadapter): preserve zero power mean exponent in label selection
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 17 Sep 2026 17:20:36 +0000 (19:20 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 17 Sep 2026 17:20:36 +0000 (19:20 +0200)
_validate_power_mean_p returns 0.0 for p=0 (a finite float accepted by
README), and the falsy fallback silently rewrote it to 1.0, turning the
documented generalized-mean p=0 (geometric) into arithmetic. Use an
explicit None check for the fallback; map-based metrics are unchanged.

Verified in the QA image (Freqtrade 2026.8): p=0 now matches
geometric_mean selection (winner 1, identical distances), while p=None
keeps the arithmetic default.

quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py

index a53374c9025e68cab00259970697bea835a4e2b4..c22143bb13548707cd02be5d427b685d88d8e80d 100644 (file)
@@ -3642,10 +3642,11 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
         mode: ValidationMode = "none",
         p_ctx: str = "p",
     ) -> NDArray[np.floating]:
+        validated_p = QuickAdapterRegressorV3._validate_power_mean_p(p, ctx=p_ctx, mode=mode)
         power = (
             QuickAdapterRegressorV3._POWER_MEAN_MAP[distance_metric]
             if distance_metric in QuickAdapterRegressorV3._POWER_MEAN_METRICS_SET
-            else (QuickAdapterRegressorV3._validate_power_mean_p(p, ctx=p_ctx, mode=mode) or 1.0)
+            else (1.0 if validated_p is None else validated_p)
         )
         if weights is None:
             weights = np.ones(matrix.shape[1])