]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3): more explicit code at MO trial selection
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 26 May 2025 20:51:22 +0000 (22:51 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 26 May 2025 20:51:22 +0000 (22:51 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py

index 4c3db586d00d341833b618dc03289e76bdedd108..fc3ff6e443471b396c36307625f58f91c6be3e25 100644 (file)
@@ -465,7 +465,11 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                     normalized_matrix - ideal_point, ord=order, axis=1
                 )
             elif metric == "hellinger":
-                return np.sqrt(np.sum((np.sqrt(normalized_matrix) - 1.0) ** 2, axis=1))
+                return np.sqrt(
+                    np.sum(
+                        (np.sqrt(normalized_matrix) - np.sqrt(ideal_point)) ** 2, axis=1
+                    )
+                )
             elif metric == "geometric_mean":
                 return 1.0 - np.prod(normalized_matrix, axis=1) ** (
                     1.0 / normalized_matrix.shape[1]
@@ -480,7 +484,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                     raise ValueError(
                         "label_weights length must match number of objectives"
                     )
-                return np.sum(np.array(weights) * (1.0 - normalized_matrix), axis=1)
+                return np.sum(
+                    np.array(weights) * (ideal_point - normalized_matrix), axis=1
+                )
             elif metric == "tchebichev":
                 weights = self.ft_params.get(
                     "label_weights", [1.0] * normalized_matrix.shape[1]
@@ -489,7 +495,9 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                     raise ValueError(
                         "label_weights length must match number of objectives"
                     )
-                return np.max(np.array(weights) * (1.0 - normalized_matrix), axis=1)
+                return np.max(
+                    np.array(weights) * (ideal_point - normalized_matrix), axis=1
+                )
             elif metric == "mahalanobis":
                 if normalized_matrix.shape[0] < 2:
                     return np.linalg.norm(