bayeso.gp.gp

It defines Gaussian process regression.

bayeso.gp.gp.predict_with_cov(X_train: numpy.ndarray, Y_train: numpy.ndarray, X_test: numpy.ndarray, cov_X_X: numpy.ndarray, inv_cov_X_X: numpy.ndarray, hyps: dict, str_cov: str = 'matern52', prior_mu: Optional[Callable] = None, debug: bool = False) → Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

This function returns posterior mean and posterior standard deviation functions over X_test, computed by Gaussian process regression with X_train, Y_train, cov_X_X, inv_cov_X_X, and hyps.

Parameters:
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • X_test (numpy.ndarray) – inputs. Shape: (l, d) or (l, m, d).
  • cov_X_X (numpy.ndarray) – kernel matrix over X_train. Shape: (n, n).
  • inv_cov_X_X (numpy.ndarray) – kernel matrix inverse over X_train. Shape: (n, n).
  • hyps (dict.) – dictionary of hyperparameters for Gaussian process.
  • str_cov (str., optional) – the name of covariance function.
  • prior_mu (NoneType, or callable, optional) – None, or prior mean function.
  • debug (bool., optional) – flag for printing log messages.
Returns:

a tuple of posterior mean function over X_test, posterior standard deviation function over X_test, and posterior covariance matrix over X_test. Shape: ((l, 1), (l, 1), (l, l)).

Return type:

tuple of (numpy.ndarray, numpy.ndarray, numpy.ndarray)

Raises:

AssertionError

bayeso.gp.gp.predict_with_hyps(X_train: numpy.ndarray, Y_train: numpy.ndarray, X_test: numpy.ndarray, hyps: dict, str_cov: str = 'matern52', prior_mu: Optional[Callable] = None, debug: bool = False) → Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

This function returns posterior mean and posterior standard deviation functions over X_test, computed by Gaussian process regression with X_train, Y_train, and hyps.

Parameters:
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • X_test (numpy.ndarray) – inputs. Shape: (l, d) or (l, m, d).
  • hyps (dict.) – dictionary of hyperparameters for Gaussian process.
  • str_cov (str., optional) – the name of covariance function.
  • prior_mu (NoneType, or callable, optional) – None, or prior mean function.
  • debug (bool., optional) – flag for printing log messages.
Returns:

a tuple of posterior mean function over X_test, posterior standard deviation function over X_test, and posterior covariance matrix over X_test. Shape: ((l, 1), (l, 1), (l, l)).

Return type:

tuple of (numpy.ndarray, numpy.ndarray, numpy.ndarray)

Raises:

AssertionError

bayeso.gp.gp.predict_with_optimized_hyps(X_train: numpy.ndarray, Y_train: numpy.ndarray, X_test: numpy.ndarray, str_cov: str = 'matern52', str_optimizer_method: str = 'BFGS', prior_mu: Optional[Callable] = None, fix_noise: float = True, debug: bool = False) → Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

This function returns posterior mean and posterior standard deviation functions over X_test, computed by the Gaussian process regression optimized with X_train and Y_train.

Parameters:
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • X_test (numpy.ndarray) – inputs. Shape: (l, d) or (l, m, d).
  • str_cov (str., optional) – the name of covariance function.
  • str_optimizer_method (str., optional) – the name of optimization method.
  • prior_mu (NoneType, or callable, optional) – None, or prior mean function.
  • fix_noise (bool., optional) – flag for fixing a noise.
  • debug (bool., optional) – flag for printing log messages.
Returns:

a tuple of posterior mean function over X_test, posterior standard deviation function over X_test, and posterior covariance matrix over X_test. Shape: ((l, 1), (l, 1), (l, l)).

Return type:

tuple of (numpy.ndarray, numpy.ndarray, numpy.ndarray)

Raises:

AssertionError

bayeso.gp.gp.sample_functions(mu: numpy.ndarray, Sigma: numpy.ndarray, num_samples: int = 1) → numpy.ndarray

It samples num_samples functions from multivariate Gaussian distribution (mu, Sigma).

Parameters:
  • mu (numpy.ndarray) – mean vector. Shape: (n, ).
  • Sigma (numpy.ndarray) – covariance matrix. Shape: (n, n).
  • num_samples (int., optional) – the number of sampled functions
Returns:

sampled functions. Shape: (num_samples, n).

Return type:

numpy.ndarray

Raises:

AssertionError