From 6275d30a2d105849c8829121c56590c85a730eab Mon Sep 17 00:00:00 2001 From: Eu Jing Chua Date: Thu, 12 Dec 2024 01:40:49 +0000 Subject: [PATCH] Initial fix --- .../optimizers/bayesian_optimizers/smac_optimizer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py b/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py index 8c73037261..6112328e1b 100644 --- a/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py +++ b/mlos_core/mlos_core/optimizers/bayesian_optimizers/smac_optimizer.py @@ -20,7 +20,6 @@ import ConfigSpace import numpy.typing as npt import pandas as pd -from smac.utils.configspace import convert_configurations_to_array from mlos_core.data_classes import Observation, Observations, Suggestion from mlos_core.optimizers.bayesian_optimizers.bayesian_optimizer import ( @@ -121,6 +120,10 @@ def __init__( from smac.main.config_selector import ConfigSelector from smac.random_design.probability_design import ProbabilityRandomDesign from smac.runhistory import TrialInfo + from smac.utils.configspace import convert_configurations_to_array + + # Save util function here as a property for later usage, also to satisfy linter + self._convert_configurations_to_array = convert_configurations_to_array # Store for TrialInfo instances returned by .ask() self.trial_info_map: Dict[ConfigSpace.Configuration, TrialInfo] = {} @@ -411,7 +414,7 @@ def surrogate_predict(self, suggestion: Suggestion) -> npt.NDArray: if self.base_optimizer._config_selector._model is None: raise RuntimeError("Surrogate model is not yet trained") - config_array = convert_configurations_to_array( + config_array = self._convert_configurations_to_array( [ ConfigSpace.Configuration( self.optimizer_parameter_space, values=suggestion.config.to_dict()