]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
!refactor(qav3): cleanup predictions handling tunables
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 20 Nov 2025 10:23:06 +0000 (11:23 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 20 Nov 2025 10:23:06 +0000 (11:23 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
README.md
quickadapter/user_data/config-template.json
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py

index 233cb0cb1e176001b0a82e46b1c6e4ad758ef1cf..07b0f2abd1fb1784d68c382e954f1d4234503eb4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -78,11 +78,11 @@ docker compose up -d --build
 | freqai.feature_parameters.label_knn_metric           | `minkowski`       | string                                                                                                                           | Distance metric for KNN.                                                                                                                                                                                   |
 | freqai.feature_parameters.label_knn_p_order          | `None`            | float                                                                                                                            | p-order for KNN Minkowski metric distance. (optional)                                                                                                                                                      |
 | freqai.feature_parameters.label_knn_n_neighbors      | 5                 | int >= 1                                                                                                                         | Number of neighbors for KNN.                                                                                                                                                                               |
-| _Prediction thresholds_                              |                   |                                                                                                                                  |                                                                                                                                                                                                            |
-| freqai.prediction_extrema_selection                  | `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.prediction_thresholds_smoothing               | `mean`            | enum {`mean`,`isodata`,`li`,`minimum`,`otsu`,`triangle`,`yen`,`soft_extremum`}                                                   | Thresholding method for prediction thresholds smoothing.                                                                                                                                                   |
-| freqai.prediction_thresholds_alpha                   | 12.0              | float > 0                                                                                                                        | Alpha for `soft_extremum`.                                                                                                                                                                                 |
-| freqai.outlier_threshold                             | 0.999             | float (0,1)                                                                                                                      | Quantile threshold for predictions outlier filtering.                                                                                                                                                      |
+| _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.thresholds_smoothing      | `mean`            | enum {`mean`,`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.                                                                                                                                                      |
 | _Optuna / HPO_                                       |                   |                                                                                                                                  |                                                                                                                                                                                                            |
 | freqai.optuna_hyperopt.enabled                       | true              | bool                                                                                                                             | Enables HPO.                                                                                                                                                                                               |
 | freqai.optuna_hyperopt.sampler                       | `tpe`             | enum {`tpe`,`auto`}                                                                                                              | HPO sampler algorithm. `tpe` uses TPESampler with multivariate and group, `auto` uses AutoSampler.                                                                                                         |
index 5e23f358c852f1b903df6ec00b03a3df6a52668a..cb1cf1bdeb640688fd114a62f047c182ff007e92 100644 (file)
     "fit_live_predictions_candles": 864,
     "data_kitchen_thread_count": 6, // set to number of CPU threads / 4
     "track_performance": false,
-    "prediction_thresholds_smoothing": "isodata",
-    "outlier_threshold": 0.999,
+    "predictions_extrema": {
+      "thresholds_smoothing": "isodata"
+    },
     "optuna_hyperopt": {
       "enabled": true,
       "n_jobs": 6,
index 055dc07e1ce25d54d267600d1e611fed954b52f6..2f45f92124b16080a20c9e54cc1847db7dcc7ef7 100644 (file)
@@ -650,8 +650,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
             f = sp.stats.weibull_min.fit(
                 pd.to_numeric(di_values, errors="coerce").dropna()
             )
+            predictions_extrema = self.freqai_info.get("predictions_extrema", {})
             cutoff = sp.stats.weibull_min.ppf(
-                self.freqai_info.get("outlier_threshold", 0.999), *f
+                predictions_extrema.get("threshold_outlier", 0.999), *f
             )
 
         dk.data["DI_value_mean"] = di_values.mean()
@@ -720,9 +721,10 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
 
         pred_extrema = pred_df.get(EXTREMA_COLUMN).iloc[-thresholds_candles:].copy()
 
+        predictions_extrema = self.freqai_info.get("predictions_extrema", {})
         extrema_selection = str(
-            self.freqai_info.get(
-                "prediction_extrema_selection",
+            predictions_extrema.get(
+                "selection_method",
                 QuickAdapterRegressorV3._EXTREMA_SELECTION_METHODS[1],
             )
         )
@@ -732,7 +734,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                 f"Supported methods are {', '.join(self._EXTREMA_SELECTION_METHODS)}"
             )
         thresholds_smoothing = str(
-            self.freqai_info.get("prediction_thresholds_smoothing", "mean")
+            predictions_extrema.get("thresholds_smoothing", "mean")
         )
         skimage_thresholds_smoothing_methods = {
             "isodata",
@@ -747,9 +749,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
             {"soft_extremum"}
         )
         if thresholds_smoothing == "soft_extremum":
-            thresholds_alpha = float(
-                self.freqai_info.get("prediction_thresholds_alpha", 12.0)
-            )
+            thresholds_alpha = float(predictions_extrema.get("thresholds_alpha", 12.0))
             return QuickAdapterRegressorV3.soft_extremum_min_max(
                 pred_extrema, thresholds_alpha, extrema_selection
             )