Coverage for mlos_core/mlos_core/optimizers/bayesian_optimizers/bayesian_optimizer.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 01:18 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 01:18 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""Contains the wrapper classes for base Bayesian optimizers."""
7from abc import ABCMeta, abstractmethod
8from typing import Optional
10import numpy.typing as npt
11import pandas as pd
13from mlos_core.optimizers.optimizer import BaseOptimizer
16class BaseBayesianOptimizer(BaseOptimizer, metaclass=ABCMeta):
17 """Abstract base class defining the interface for Bayesian optimization."""
19 @abstractmethod
20 def surrogate_predict(
21 self,
22 *,
23 configs: pd.DataFrame,
24 context: Optional[pd.DataFrame] = None,
25 ) -> npt.NDArray:
26 """
27 Obtain a prediction from this Bayesian optimizer's surrogate model for the given
28 configuration(s).
30 Parameters
31 ----------
32 configs : pandas.DataFrame
33 Dataframe of configs / parameters. The columns are parameter names and
34 the rows are the configs.
36 context : pandas.DataFrame
37 Not Yet Implemented.
38 """
39 pass # pylint: disable=unnecessary-pass # pragma: no cover
41 @abstractmethod
42 def acquisition_function(
43 self,
44 *,
45 configs: pd.DataFrame,
46 context: Optional[pd.DataFrame] = None,
47 ) -> npt.NDArray:
48 """
49 Invokes the acquisition function from this Bayesian optimizer for the given
50 configuration.
52 Parameters
53 ----------
54 configs : pandas.DataFrame
55 Dataframe of configs / parameters. The columns are parameter names and
56 the rows are the configs.
58 context : pandas.DataFrame
59 Not Yet Implemented.
60 """
61 pass # pylint: disable=unnecessary-pass # pragma: no cover