]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(weights): pivot-only sample weights when label_weighting is active
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 25 May 2026 01:39:28 +0000 (03:39 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 25 May 2026 01:39:28 +0000 (03:39 +0200)
Replace the full-series median fill with 0.0 in compute_label_weights so
non-pivot rows carry no sample weight when a label_weighting strategy is
configured. The median fill predates PR #72: when weights multiplied the
label, the fill was inert (label=0 × median=0). Once weights became the
sample_weight kwarg of model.fit, the fill silently leaked the median
into the training loss for every non-pivot row, diluting the pivot
detection signal the model is being trained for.

Concretely, training now concentrates on pivots and their smoothed
neighborhoods (via label_smoothing), and the raw/smoothed weight plots
both render clean profiles starting from zero.

strategy='none' (the default) is unaffected: compute_label_weights still
returns a uniform 1.0 vector and every row contributes equally.

quickadapter/user_data/strategies/Utils.py

index 2c93905c4be5cd4254357b924d90002cd26f205f..873b389ea842462e50d0f92330b85aceb928cb33 100644 (file)
@@ -1176,7 +1176,7 @@ def compute_label_weights(
         n_values=n_values,
         indices=indices,
         weights=weights,
-        default_weight=float(np.nanmedian(weights)),
+        default_weight=0.0,
     )