From: Jérôme Benoit Date: Tue, 27 May 2025 07:24:47 +0000 (+0200) Subject: docs: add some comments for metric definition in MO trial selection X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ee855fd4c74bfe22d576142862a32d5a3a00e4ca;p=freqai-strategies.git docs: add some comments for metric definition in MO trial selection Signed-off-by: Jérôme Benoit --- diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index fc3ff6e..b303466 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -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)]