Add possibility to override estimator from within hyperopt

This commit is contained in:
Matthias
2021-09-15 21:36:53 +02:00
parent 90ad178932
commit c0811ae896
4 changed files with 54 additions and 4 deletions

View File

@@ -365,10 +365,14 @@ class Hyperopt:
}
def get_optimizer(self, dimensions: List[Dimension], cpu_count) -> Optimizer:
estimator = self.custom_hyperopt.generate_estimator()
logger.info(f"Using estimator {estimator}.")
# TODO: Impact of changing acq_optimizer to "sampling" is unclear
# (other than that it fails with other optimizers when using custom sklearn regressors)
return Optimizer(
dimensions,
base_estimator="ET",
acq_optimizer="auto",
base_estimator=estimator,
acq_optimizer="sampling",
n_initial_points=INITIAL_POINTS,
acq_optimizer_kwargs={'n_jobs': cpu_count},
random_state=self.random_state,