]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
docs: add some comments for metric definition in MO trial selection
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 27 May 2025 07:24:47 +0000 (09:24 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 27 May 2025 07:24:47 +0000 (09:24 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py

index fc3ff6e443471b396c36307625f58f91c6be3e25..b303466a9ed04565e5e9660a5b4789997c600eb8 100644 (file)
@@ -447,7 +447,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
         def calculate_distances(
             normalized_matrix: np.ndarray,
             metric: str,
-            p_order: float = self.ft_params.get("label_p_order", 2.0),
+            p_order: float,
         ) -> np.ndarray:
             ideal_point = np.ones(normalized_matrix.shape[1])
 
@@ -471,10 +471,12 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                     )
                 )
             elif metric == "geometric_mean":
+                # 1.0 = np.prod(ideal_point) ** (1.0 / ideal_point.shape[0])
                 return 1.0 - np.prod(normalized_matrix, axis=1) ** (
                     1.0 / normalized_matrix.shape[1]
                 )
             elif metric == "hypervolume":
+                # 1.0 = np.prod(ideal_point)
                 return 1.0 - np.prod(normalized_matrix, axis=1)
             elif metric == "weighted_sum":
                 weights = self.ft_params.get(
@@ -580,7 +582,11 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                             finite_max_val - finite_col
                         ) / finite_range_val
 
-        trial_distances = calculate_distances(normalized_matrix, label_metric)
+        trial_distances = calculate_distances(
+            normalized_matrix,
+            metric=label_metric,
+            p_order=self.ft_params.get("label_p_order", 2.0),
+        )
 
         return best_trials[np.argmin(trial_distances)]