From: Jérôme Benoit Date: Mon, 26 May 2025 14:44:00 +0000 (+0200) Subject: refactor(qav3): cleanup pivots labeling tunables namespace X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8752dad331536f48473c80d7a35d04288d8a97c7;p=freqai-strategies.git refactor(qav3): cleanup pivots labeling tunables namespace Signed-off-by: Jérôme Benoit --- diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index 0e595a5..6b2a394 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -405,13 +405,11 @@ class QuickAdapterRegressorV3(BaseRegressionModel): n_objectives = len(study.directions) - label_trials_selection = self.ft_params.get( - "label_trials_selection", "euclidean" - ) + label_metric = self.ft_params.get("label_metric", "euclidean") metrics = {"euclidean", "chebyshev", "manhattan", "minkowski"} - if label_trials_selection not in metrics: + if label_metric not in metrics: raise ValueError( - f"Unsupported label trials selection method: {label_trials_selection}. Supported methods are {', '.join(metrics)}" + f"Unsupported label metric: {label_metric}. Supported metrics are {', '.join(metrics)}" ) best_trials = [] @@ -431,23 +429,26 @@ class QuickAdapterRegressorV3(BaseRegressionModel): return None def calculate_distances( - normalized: np.ndarray, + normalized_matrix: np.ndarray, metric: str, p_order: float = self.ft_params.get("label_p_order", 2.0), ) -> np.ndarray: - ideal_point = np.full(normalized.shape[1], 1.0) + ideal_point = np.full(normalized_matrix.shape[1], 1.0) if metric == "euclidean": - return np.linalg.norm(normalized - ideal_point, axis=1) + return np.linalg.norm(normalized_matrix - ideal_point, axis=1) elif metric == "chebyshev": - return np.max(np.abs(normalized - ideal_point), axis=1) + return np.max(np.abs(normalized_matrix - ideal_point), axis=1) elif metric == "manhattan": - return np.sum(np.abs(normalized - ideal_point), axis=1) + return np.sum(np.abs(normalized_matrix - ideal_point), axis=1) elif metric == "minkowski": if p_order < 1: raise ValueError("Minkowski p_order must be >= 1") return np.power( - np.sum(np.power(np.abs(normalized - ideal_point), p_order), axis=1), + np.sum( + np.power(np.abs(normalized_matrix - ideal_point), p_order), + axis=1, + ), 1.0 / p_order, ) else: @@ -504,7 +505,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): finite_max_val - finite_col ) / finite_range_val - trial_distances = calculate_distances(normalized_matrix, label_trials_selection) + trial_distances = calculate_distances(normalized_matrix, label_metric) return best_trials[np.argmin(trial_distances)]