From: Jérôme Benoit Date: Fri, 21 Nov 2025 09:29:35 +0000 (+0100) Subject: refactor(qav3)!: sensible tunables namespace X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d356376449ae28e9cf3fb358e0cc2f7f270b9d0d;p=freqai-strategies.git refactor(qav3)!: sensible tunables namespace Signed-off-by: Jérôme Benoit --- diff --git a/README.md b/README.md index 2604725..804b289 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ docker compose up -d --build | freqai.extrema_smoothing.window | 5 | int >= 3 | Window size for extrema smoothing. | | freqai.extrema_smoothing.beta | 8.0 | float > 0 | Kaiser kernel shape parameter. | | _Extrema weighting_ | | | | -| freqai.extrema_weighting.strategy | `none` | enum {`none`,`pivot_threshold`} | Weighting strategy applied before smoothing. | +| freqai.extrema_weighting.strategy | `none` | enum {`none`,`threshold`} | Weighting strategy applied before smoothing. | | freqai.extrema_weighting.normalization | `minmax` | enum {`minmax`,`l1`,`none`} | Normalization method for weights. | | freqai.extrema_weighting.gamma | 1.0 | float (0,10] | Contrast exponent applied after normalization (>1 emphasizes extremes, 0= 1 | Number of neighbors for KNN. | | _Predictions extrema_ | | | | -| freqai.predictions_extrema.selection_method | `extrema_rank` | enum {`peak_values`,`extrema_rank`,`partition`} | Extrema selection method. `peak_values` uses detected peaks, `extrema_rank` uses ranked extrema values, `partition` uses sign-based extrema partitioning. | +| freqai.predictions_extrema.selection_method | `rank` | enum {`values`,`rank`,`partition`} | Extrema selection method. `values` uses reversal values, `rank` uses ranked extrema values, `partition` uses sign-based partitioning. | | freqai.predictions_extrema.thresholds_smoothing | `mean` | enum {`mean`,`median`,`isodata`,`li`,`minimum`,`otsu`,`triangle`,`yen`,`soft_extremum`} | Thresholding method for prediction thresholds smoothing. | | freqai.predictions_extrema.thresholds_alpha | 12.0 | float > 0 | Alpha for `soft_extremum`. | | freqai.predictions_extrema.threshold_outlier | 0.999 | float (0,1) | Quantile threshold for predictions outlier filtering. | diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index 007d580..a1e1e6e 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -33,7 +33,7 @@ from Utils import ( zigzag, ) -ExtremaSelectionMethod = Literal["peak_values", "extrema_rank", "partition"] +ExtremaSelectionMethod = Literal["values", "rank", "partition"] OptunaNamespace = Literal["hp", "train", "label"] CustomThresholdMethod = Literal["median", "soft_extremum"] SkimageThresholdMethod = Literal[ @@ -76,8 +76,8 @@ class QuickAdapterRegressorV3(BaseRegressionModel): _SQRT_2: Final[float] = np.sqrt(2.0) _EXTREMA_SELECTION_METHODS: Final[tuple[ExtremaSelectionMethod, ...]] = ( - "peak_values", - "extrema_rank", + "values", + "rank", "partition", ) _CUSTOM_THRESHOLD_METHODS: Final[tuple[CustomThresholdMethod, ...]] = ( @@ -812,7 +812,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel): if pred_extrema.empty: return pd.Series(dtype=float), pd.Series(dtype=float) - if extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[0]: + if ( + extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[0] + ): # "values" minima_indices = sp.signal.find_peaks(-pred_extrema)[0] maxima_indices = sp.signal.find_peaks(pred_extrema)[0] @@ -826,7 +828,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel): if maxima_indices.size > 0 else pd.Series(dtype=float) ) - elif extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[1]: + elif ( + extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[1] + ): # "rank" minima_indices = sp.signal.find_peaks(-pred_extrema)[0] maxima_indices = sp.signal.find_peaks(pred_extrema)[0] @@ -842,7 +846,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel): pred_maxima = pred_extrema.nlargest(n_maxima) else: pred_maxima = pd.Series(dtype=float) - elif extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[2]: + elif ( + extrema_selection == QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[2] + ): # "partition" eps = np.finfo(float).eps pred_maxima = pred_extrema[pred_extrema > eps] diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index f444d7a..50023dc 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -18,8 +18,8 @@ from technical import qtpylib T = TypeVar("T", pd.Series, float) -WeightStrategy = Literal["none", "pivot_threshold"] -WEIGHT_STRATEGIES: Final[tuple[WeightStrategy, ...]] = ("none", "pivot_threshold") +WeightStrategy = Literal["none", "threshold"] +WEIGHT_STRATEGIES: Final[tuple[WeightStrategy, ...]] = ("none", "threshold") NormalizationType = Literal["minmax", "l1", "none"] NORMALIZATION_TYPES: Final[tuple[NormalizationType, ...]] = ("minmax", "l1", "none") @@ -259,7 +259,7 @@ def get_weighted_extrema( ): # "none" return extrema, default_weights - if strategy == WEIGHT_STRATEGIES[1]: # "pivot_threshold" + if strategy == WEIGHT_STRATEGIES[1]: # "threshold" extrema_weights = calculate_extrema_weights( series=extrema, indices=indices,