bayeso.utils.utils_covariance

It is utilities for covariance functions.

bayeso.utils.utils_covariance._get_list_first() → List[str]

It provides list of strings. The strings in that list require two hyperparameters, signal and lengthscales. We simply call it as list_first.

Returns:list of strings, which satisfy some requirements we mentioned above.
Return type:list
bayeso.utils.utils_covariance.check_str_cov(str_fun: str, str_cov: str, shape_X1: tuple, shape_X2: tuple = None) → None

It is for validating the shape of X1 (and optionally the shape of X2).

Parameters:
  • str_fun (str.) – the name of function.
  • str_cov (str.) – the name of covariance function.
  • shape_X1 (tuple) – the shape of X1.
  • shape_X2 (NoneType or tuple, optional) – None, or the shape of X2.
Returns:

None, if it is valid. Raise an error, otherwise.

Return type:

NoneType

Raises:

AssertionError, ValueError

bayeso.utils.utils_covariance.convert_hyps(str_cov: str, hyps: dict, use_gp: bool = True, fix_noise: bool = False) → numpy.ndarray

It converts hyperparameters dictionary, hyps to numpy array.

Parameters:
  • str_cov (str.) – the name of covariance function.
  • hyps (dict.) – dictionary of hyperparameters for covariance function.
  • use_gp (bool., optional) – flag for Gaussian process or Student-$t$ process.
  • fix_noise (bool., optional) – flag for fixing a noise.
Returns:

converted array of the hyperparameters given by hyps.

Return type:

numpy.ndarray

Raises:

AssertionError

bayeso.utils.utils_covariance.get_hyps(str_cov: str, dim: int, use_gp: bool = True, use_ard: bool = True) → dict

It returns a dictionary of default hyperparameters for covariance function, where str_cov and dim are given. If use_ard is True, the length scales would be dim-dimensional vector.

Parameters:
  • str_cov (str.) – the name of covariance function.
  • dim (int.) – dimensionality of the problem we are solving.
  • use_gp (bool., optional) – flag for Gaussian process or Student-$t$ process.
  • use_ard (bool., optional) – flag for automatic relevance determination.
Returns:

dictionary of default hyperparameters for covariance function.

Return type:

dict.

Raises:

AssertionError

bayeso.utils.utils_covariance.get_range_hyps(str_cov: str, dim: int, use_gp: bool = True, use_ard: bool = True, fix_noise: bool = False) → List[list]

It returns default optimization ranges of hyperparameters for Gaussian process regression.

Parameters:
  • str_cov (str.) – the name of covariance function.
  • dim (int.) – dimensionality of the problem we are solving.
  • use_gp (bool., optional) – flag for Gaussian process or Student-$t$ process.
  • use_ard (bool., optional) – flag for automatic relevance determination.
  • fix_noise (bool., optional) – flag for fixing a noise.
Returns:

list of default optimization ranges for hyperparameters.

Return type:

list

Raises:

AssertionError

bayeso.utils.utils_covariance.restore_hyps(str_cov: str, hyps: numpy.ndarray, use_gp: bool = True, use_ard: bool = True, fix_noise: bool = False, noise: float = 0.01) → dict

It restores hyperparameters array, hyps to dictionary.

Parameters:
  • str_cov (str.) – the name of covariance function.
  • hyps (numpy.ndarray) – array of hyperparameters for covariance function.
  • use_gp (bool., optional) – flag for Gaussian process or Student-$t$ process.
  • use_ard (bool., optional) – flag for using automatic relevance determination.
  • fix_noise (bool., optional) – flag for fixing a noise.
  • noise (float, optional) – fixed noise value.
Returns:

restored dictionary of the hyperparameters given by hyps.

Return type:

dict.

Raises:

AssertionError

bayeso.utils.utils_covariance.validate_hyps_arr(hyps: numpy.ndarray, str_cov: str, dim: int, use_gp: bool = True) → Tuple[numpy.ndarray, bool]

It validates hyperparameters array, hyps.

Parameters:
  • hyps (numpy.ndarray) – array of hyperparameters for covariance function.
  • str_cov (str.) – the name of covariance function.
  • dim (int.) – dimensionality of the problem we are solving.
  • use_gp (bool., optional) – flag for Gaussian process or Student-$t$ process.
Returns:

a tuple of valid hyperparameters and validity flag.

Return type:

(numpy.ndarray, bool.)

Raises:

AssertionError

bayeso.utils.utils_covariance.validate_hyps_dict(hyps: dict, str_cov: str, dim: int, use_gp: bool = True) → Tuple[dict, bool]

It validates hyperparameters dictionary, hyps.

Parameters:
  • hyps (dict.) – dictionary of hyperparameters for covariance function.
  • str_cov (str.) – the name of covariance function.
  • dim (int.) – dimensionality of the problem we are solving.
  • use_gp (bool., optional) – flag for Gaussian process or Student-$t$ process.
Returns:

a tuple of valid hyperparameters and validity flag.

Return type:

(dict., bool.)

Raises:

AssertionError