]> Piment Noir Git Repositories - freqai-strategies.git/commit
feat(label_weighting): adaptive k-NN bandwidth for gaussian off-pivot fill (#77)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 4 Jun 2026 22:29:58 +0000 (00:29 +0200)
committerGitHub <noreply@github.com>
Thu, 4 Jun 2026 22:29:58 +0000 (00:29 +0200)
commitd54e9e5608f8b8e0bb6f1bc891b6f7eff45381f8
tree439907d6b5fee6282c5609e7f8f476519b4333f9
parent50a4fd2cb6fa35c8771c9c0bf2aa0468ebc929d8
feat(label_weighting): adaptive k-NN bandwidth for gaussian off-pivot fill (#77)

* feat(label_weighting): adaptive k-NN bandwidth for gaussian off-pivot fill

Address the crushing of weaker pivots by stronger neighbors when pivots
fall within ~sigma_candles of each other in fill_method='gaussian'. The
per-row max aggregator preserves the upper bound Out[i] <= max_p w_p
but a wide constant sigma lets a strong neighbor's Gaussian dominate a
weak pivot's tail.

Add a k-nearest-neighbor bandwidth selector (Loftsgaarden &
Quesenberry 1965; Silverman 1986, paragraph 5.2) that adapts each
pivot's sigma to local pivot density:

    sigma_p = clip(alpha * d_k(p), sigma_min, sigma_max)

where d_k(p) is the index distance to the k-th pivot neighbor. The
upper bound on Out[i] is preserved (no over-amplification) and dense
clusters automatically contract their Gaussians to stop overlapping.

Implementation:
- Pivots are emitted chronologically by zigzag, so the 1D k-NN reduces
  to a sliding k-window over sorted indices, O(M) without a spatial
  index.
- _gaussian_fill_weights accepts a per-pivot sigma vector via NumPy
  broadcasting; the existing chunked exp/multiply/max kernel is
  unchanged.
- Default fill_bandwidth='fixed' preserves byte-for-byte the previous
  algorithm.

Tunables (added to DEFAULTS_LABEL_WEIGHTING, validated via _WEIGHTING_SPECS):
- fill_bandwidth: 'fixed' | 'knn' (default 'fixed')
- fill_bandwidth_neighbors: int >= 1 (default 1)
- fill_bandwidth_alpha: float > 0 (default 1.0)
- fill_sigma_min_candles: float >= 0.5 (default 0.5)

README updated.

* fix(label_weighting): correct gaussian kNN bandwidth

* chore(quickadapter): bump strategy and regressor version 3.11.12 -> 3.11.13
README.md
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/LabelTransformer.py
quickadapter/user_data/strategies/QuickAdapterV3.py
quickadapter/user_data/strategies/Utils.py