From: Jérôme Benoit Date: Wed, 28 May 2025 21:36:45 +0000 (+0200) Subject: refactor(qav3): consolidate hellinger distance computation code X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2989134db8ed709580f3b9fa9b704ee1ca380826;p=freqai-strategies.git refactor(qav3): consolidate hellinger distance computation code Signed-off-by: Jérôme Benoit --- 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