| 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. |
// }
// }
},
- "sample_weighting": {
- "aggregation": "arithmetic_mean",
- "softmax_temperature": 1.0
- },
"label_smoothing": {
"method": "kaiser",
"window_candles": 5,
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,
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(
"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),
DEFAULTS_LABEL_PREDICTION,
DEFAULTS_LABEL_SMOOTHING,
DEFAULTS_LABEL_WEIGHTING,
- DEFAULTS_SAMPLE_WEIGHTING,
EXTREMA_SELECTION_METHODS,
NORMALIZATION_TYPES,
PREDICTION_METHODS,
),
}
-_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)),
)
-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,