]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(quickadapter): improve outlier detection fitting
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 25 Dec 2025 19:39:03 +0000 (20:39 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 25 Dec 2025 19:39:03 +0000 (20:39 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ReforceXY/reward_space_analysis/tests/api/test_api_helpers.py
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py

index 4c6ba58dce3f514c68ca6b408bc306de2a91ddd9..d07eaacefffd29f66bd3b8494ebcd50302b98435 100644 (file)
@@ -299,7 +299,7 @@ class TestAPIAndHelpers(RewardSpaceTestBase):
                 "test_output",
             ]
         )
-        self.assertEqual(args.num_samples, 100)
+        self.assertEqual(args.num_samples, SCENARIOS.SAMPLE_SIZE_SMALL)
         self.assertEqual(str(args.out_dir), "test_output")
 
     def test_complete_statistical_analysis_writer(self):
index 3ee30160c5e55fbfef71cbb983c14cfe4551b908..462c391aeb53e57fa4193d5ad926dd15a3c479b2 100644 (file)
@@ -311,8 +311,10 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
             "threshold_outlier",
             QuickAdapterRegressorV3.PREDICTIONS_EXTREMA_THRESHOLD_OUTLIER_DEFAULT,
         )
-        if not isinstance(threshold_outlier, (int, float)) or not (
-            0 < threshold_outlier < 1
+        if (
+            not isinstance(threshold_outlier, (int, float))
+            or not np.isfinite(threshold_outlier)
+            or not (0 < threshold_outlier < 1)
         ):
             threshold_outlier = (
                 QuickAdapterRegressorV3.PREDICTIONS_EXTREMA_THRESHOLD_OUTLIER_DEFAULT
@@ -345,7 +347,11 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
             "thresholds_alpha",
             QuickAdapterRegressorV3.PREDICTIONS_EXTREMA_THRESHOLDS_ALPHA_DEFAULT,
         )
-        if not isinstance(thresholds_alpha, (int, float)) or thresholds_alpha < 0:
+        if (
+            not isinstance(thresholds_alpha, (int, float))
+            or not np.isfinite(thresholds_alpha)
+            or thresholds_alpha < 0
+        ):
             thresholds_alpha = (
                 QuickAdapterRegressorV3.PREDICTIONS_EXTREMA_THRESHOLDS_ALPHA_DEFAULT
             )
@@ -1147,13 +1153,13 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
 
         di_values = pred_df.get("DI_values")
 
-        # fit the DI_threshold
+        # Fit DI_value cutoff
         if not warmed_up:
-            f = [0, 0, 0]
-            cutoff = 2
+            f = [0.0, 0.0, 0.0]
+            cutoff = 2.0
         else:
             f = sp.stats.weibull_min.fit(
-                pd.to_numeric(di_values, errors="coerce").dropna()
+                pd.to_numeric(di_values, errors="coerce").dropna(), floc=0
             )
             cutoff = sp.stats.weibull_min.ppf(
                 self.predictions_extrema["threshold_outlier"], *f