From 348fa15e87405dfaf269de968f6bd6e7bfd73f7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 25 May 2026 01:44:44 +0200 Subject: [PATCH] refactor(quickadapter): drop unused sample_weighting tunables 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 | 3 -- quickadapter/user_data/config-template.json | 4 --- .../freqaimodels/QuickAdapterRegressorV3.py | 7 ----- .../user_data/strategies/LabelTransformer.py | 5 --- quickadapter/user_data/strategies/Utils.py | 31 ------------------- 5 files changed, 50 deletions(-) diff --git a/README.md b/README.md index 54e81fc..90d4a87 100644 --- 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. | diff --git a/quickadapter/user_data/config-template.json b/quickadapter/user_data/config-template.json index 08aa8ee..acca7c9 100644 --- a/quickadapter/user_data/config-template.json +++ b/quickadapter/user_data/config-template.json @@ -109,10 +109,6 @@ // } // } }, - "sample_weighting": { - "aggregation": "arithmetic_mean", - "softmax_temperature": 1.0 - }, "label_smoothing": { "method": "kaiser", "window_candles": 5, diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index 6c2157f..703eb41 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -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( diff --git a/quickadapter/user_data/strategies/LabelTransformer.py b/quickadapter/user_data/strategies/LabelTransformer.py index ca658d7..11f93b8 100644 --- a/quickadapter/user_data/strategies/LabelTransformer.py +++ b/quickadapter/user_data/strategies/LabelTransformer.py @@ -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), diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index da542dc..2dc999c 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -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, -- 2.53.0