Coverage for mlos_core/mlos_core/optimizers/bayesian_optimizers/bayesian_optimizer.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-07 01:52 +0000

1# 

2# Copyright (c) Microsoft Corporation. 

3# Licensed under the MIT License. 

4# 

5"""Contains the wrapper classes for base Bayesian optimizers.""" 

6 

7from abc import ABCMeta, abstractmethod 

8from typing import Optional 

9 

10import numpy.typing as npt 

11import pandas as pd 

12 

13from mlos_core.optimizers.optimizer import BaseOptimizer 

14 

15 

16class BaseBayesianOptimizer(BaseOptimizer, metaclass=ABCMeta): 

17 """Abstract base class defining the interface for Bayesian optimization.""" 

18 

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). 

29 

30 Parameters 

31 ---------- 

32 configs : pd.DataFrame 

33 Dataframe of configs / parameters. The columns are parameter names and 

34 the rows are the configs. 

35 

36 context : pd.DataFrame 

37 Not Yet Implemented. 

38 """ 

39 pass # pylint: disable=unnecessary-pass # pragma: no cover 

40 

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. 

51 

52 Parameters 

53 ---------- 

54 configs : pd.DataFrame 

55 Dataframe of configs / parameters. The columns are parameter names and 

56 the rows are the configs. 

57 

58 context : pd.DataFrame 

59 Not Yet Implemented. 

60 """ 

61 pass # pylint: disable=unnecessary-pass # pragma: no cover