From 2989134db8ed709580f3b9fa9b704ee1ca380826 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 28 May 2025 23:36:45 +0200 Subject: [PATCH] refactor(qav3): consolidate hellinger distance computation code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../freqaimodels/QuickAdapterRegressorV3.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index 2392359..8980184 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -45,7 +45,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel): https://github.com/sponsors/robcaulk """ - version = "3.7.73" + version = "3.7.74" @cached_property def _optuna_config(self) -> dict: @@ -511,17 +511,10 @@ class QuickAdapterRegressorV3(BaseRegressionModel): metric=metric, **cdist_kwargs, ).flatten() - elif metric == "hellinger": - return np.sqrt( - np.sum( - np_weights - * (np.sqrt(normalized_matrix) - np.sqrt(ideal_point)) ** 2, - axis=1, - ) - ) / np.sqrt(2.0) - elif metric == "shellinger": + elif metric in {"hellinger", "shellinger"}: np_sqrt_normalized_matrix = np.sqrt(normalized_matrix) - np_weights = 1 / np.var(np_sqrt_normalized_matrix, axis=0, ddof=1) + if metric == "shellinger": + np_weights = 1 / np.var(np_sqrt_normalized_matrix, axis=0, ddof=1) return np.sqrt( np.sum( np_weights -- 2.53.0