]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(quickadapter): drop unused sample_weighting tunables
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 24 May 2026 23:44:44 +0000 (01:44 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 24 May 2026 23:44:44 +0000 (01:44 +0200)
The sample_weighting.{aggregation,softmax_temperature} options were inert:
LABEL_COLUMNS is single-label by design and compose_sample_weights only
ever sees one per-label vector, making row-wise aggregation an identity
operation regardless of the configured mode.

Removes the config block, validation specs, getter, and README entry;
compose_sample_weights keeps its kwargs with safe defaults (arithmetic_mean,
T=1.0) so the call site stays trivial.

README.md
quickadapter/user_data/config-template.json
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/LabelTransformer.py
quickadapter/user_data/strategies/Utils.py

index 54e81fceafcc23d83fa2b62593e81523abb5b5cf..90d4a872ea1a50f14c2fc09291e8b38d3992b1a3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -79,9 +79,6 @@ docker compose up -d --build
 | freqai.label_weighting.metric_coefficients                     | {}                            | dict[str, float]                                                                                                                             | Per-metric coefficients for `combined` strategy. Keys: `amplitude`, `amplitude_threshold_ratio`, `volume_rate`, `speed`, `efficiency_ratio`, `volume_weighted_efficiency_ratio`.                                                                                                                                                                                                                                                                                                   |
 | freqai.label_weighting.aggregation                             | `arithmetic_mean`             | enum {`arithmetic_mean`,`geometric_mean`,`harmonic_mean`,`quadratic_mean`,`weighted_median`,`softmax`}                                       | Metric aggregation method for `combined` strategy. `arithmetic_mean`=(Σ(w·m)/Σ(w)), `geometric_mean`=(∏(m^w))^(1/Σw), `harmonic_mean`=Σ(w)/(Σ(w/m)), `quadratic_mean`=(Σ(w·m²)/Σ(w))^(1/2), `weighted_median`=Q₀.₅(m,w), `softmax`=Σ(m·s_i) where s_i=w_i·exp(m_i/T)/Σ(w_j·exp(m_j/T)).                                                                                                                                                                                            |
 | freqai.label_weighting.softmax_temperature                     | 1.0                           | float > 0                                                                                                                                    | Temperature T for `softmax` aggregation, controls distribution sharpness.                                                                                                                                                                                                                                                                                                                                                                                                          |
-| _Sample weighting_                                             |                               |                                                                                                                                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
-| freqai.sample_weighting.aggregation                            | `arithmetic_mean`             | enum {`arithmetic_mean`,`geometric_mean`,`harmonic_mean`,`quadratic_mean`,`weighted_median`,`softmax`}                                       | Row-wise aggregation of per-label weights produced by `label_weighting`. The aggregated vector is multiplied with freqtrade's recency weights, renormalized to mean=1, and passed to `model.fit(sample_weight=...)`. No-op when a single label is configured.                                                                                                                                                                                                                      |
-| freqai.sample_weighting.softmax_temperature                    | 1.0                           | float > 0                                                                                                                                    | Temperature T for `softmax` aggregation, controls distribution sharpness.                                                                                                                                                                                                                                                                                                                                                                                                          |
 | _Label pipeline_                                               |                               |                                                                                                                                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
 | freqai.label_pipeline.standardization                          | `none`                        | enum {`none`,`zscore`,`robust`,`mmad`,`power_yj`}                                                                                            | Standardization method applied to labels before normalization. `none`=w, `zscore`=(w-μ)/σ, `robust`=(w-median)/(Q₃-Q₁), `mmad`=(w-median)/(MAD·k), `power_yj`=YJ(w).                                                                                                                                                                                                                                                                                                               |
 | freqai.label_pipeline.robust_quantiles                         | [0.25, 0.75]                  | list[float] where 0 <= Q1 < Q3 <= 1                                                                                                          | Quantile range for robust standardization, Q1 and Q3.                                                                                                                                                                                                                                                                                                                                                                                                                              |
index 08aa8ee4dd11e9e1be1d0eb092b1c9a0a4450f08..acca7c96eec80e8e1a1dbb4654f72f18a51962af 100644 (file)
       //   }
       // }
     },
-    "sample_weighting": {
-      "aggregation": "arithmetic_mean",
-      "softmax_temperature": 1.0
-    },
     "label_smoothing": {
       "method": "kaiser",
       "window_candles": 5,
index 6c2157fc2897452e699e1cad002c1c75e55bc31a..703eb41246c8a6ee520e107779d1eb2653f3fe4f 100644 (file)
@@ -60,7 +60,6 @@ from Utils import (
     get_label_defaults,
     get_label_pipeline_config,
     get_label_prediction_config,
-    get_sample_weighting_config,
     get_min_max_label_period_candles,
     get_optuna_study_model_parameters,
     label_weight_column_name,
@@ -1577,16 +1576,10 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                 f"no per-label weight columns found (expected: {sorted(missing)}); "
                 f"falling back to temporal weights only"
             )
-        sample_weighting = get_sample_weighting_config(
-            self.freqai_info.get("sample_weighting", {}), logger
-        )
-        sample_weighting_default = sample_weighting["default"]
         return compose_sample_weights(
             temporal,
             per_label,
             logger=logger,
-            aggregation=sample_weighting_default["aggregation"],
-            softmax_temperature=sample_weighting_default["softmax_temperature"],
         )
 
     def _train_common(
index ca658d7cbb720e74b4703b7cbb8ff31c82e4d483..11f93b8e9b6de4ff6a03a4824143f20121578be3 100644 (file)
@@ -87,11 +87,6 @@ DEFAULTS_LABEL_WEIGHTING: Final[dict[str, Any]] = {
     "softmax_temperature": 1.0,
 }
 
-DEFAULTS_SAMPLE_WEIGHTING: Final[dict[str, Any]] = {
-    "aggregation": COMBINED_AGGREGATIONS[0],  # "arithmetic_mean"
-    "softmax_temperature": 1.0,
-}
-
 DEFAULTS_LABEL_PIPELINE: Final[dict[str, Any]] = {
     "standardization": STANDARDIZATION_TYPES[0],  # "none"
     "robust_quantiles": (0.25, 0.75),
index da542dc25e94e84f848c093cfb10496921eb2a8f..2dc999c06cadc7a2ee0d69faa65c1bdeb49dfa78 100644 (file)
@@ -32,7 +32,6 @@ from LabelTransformer import (
     DEFAULTS_LABEL_PREDICTION,
     DEFAULTS_LABEL_SMOOTHING,
     DEFAULTS_LABEL_WEIGHTING,
-    DEFAULTS_SAMPLE_WEIGHTING,
     EXTREMA_SELECTION_METHODS,
     NORMALIZATION_TYPES,
     PREDICTION_METHODS,
@@ -231,13 +230,6 @@ _SMOOTHING_SPECS: Final[dict[str, _ParamSpec]] = {
     ),
 }
 
-_SAMPLE_WEIGHTING_SPECS: Final[dict[str, _ParamSpec]] = {
-    "aggregation": _ParamSpec(_EnumValidator(COMBINED_AGGREGATIONS)),
-    "softmax_temperature": _ParamSpec(
-        _NumericValidator(min_value=0, min_exclusive=True)
-    ),
-}
-
 _PREDICTION_SPECS: Final[dict[str, _ParamSpec]] = {
     "method": _ParamSpec(_EnumValidator(PREDICTION_METHODS)),
     "selection_method": _ParamSpec(_EnumValidator(EXTREMA_SELECTION_METHODS)),
@@ -664,29 +656,6 @@ def get_label_smoothing_config(
     )
 
 
-def _validate_sample_weighting_params(
-    config: dict[str, Any],
-    logger: Logger,
-    config_name: str = "sample_weighting",
-) -> dict[str, Any]:
-    return _validate_params(
-        config, logger, config_name, _SAMPLE_WEIGHTING_SPECS, DEFAULTS_SAMPLE_WEIGHTING
-    )
-
-
-def get_sample_weighting_config(
-    config: dict[str, Any],
-    logger: Logger,
-) -> dict[str, Any]:
-    return _get_label_config(
-        config,
-        logger,
-        "sample_weighting",
-        _validate_sample_weighting_params,
-        DEFAULTS_SAMPLE_WEIGHTING,
-    )
-
-
 def _validate_prediction_params(
     config: dict[str, Any],
     logger: Logger,