bayeso.gp.gp_scipy

It is Gaussian process regression implementations with SciPy.

bayeso.gp.gp_scipy.get_optimized_kernel(X_train: numpy.ndarray, Y_train: numpy.ndarray, prior_mu: Optional[callable], str_cov: str, str_optimizer_method: str = 'BFGS', str_modelselection_method: str = 'ml', fix_noise: bool = True, debug: bool = False) → Tuple[numpy.ndarray, numpy.ndarray, dict]

This function computes the kernel matrix optimized by optimization method specified, its inverse matrix, and the optimized hyperparameters.

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

a tuple of kernel matrix over X_train, kernel matrix inverse, and dictionary of hyperparameters.

Return type:

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

Raises:

AssertionError, ValueError

bayeso.gp.gp_scipy.neg_log_ml(X_train: numpy.ndarray, Y_train: numpy.ndarray, hyps: numpy.ndarray, str_cov: str, prior_mu_train: numpy.ndarray, fix_noise: bool = True, use_cholesky: bool = True, use_gradient: bool = True, debug: bool = False) → Union[float, Tuple[float, float]]

This function computes a negative log marginal likelihood.

Parameters:
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • hyps (numpy.ndarray) – hyperparameters for Gaussian process. Shape: (h, ).
  • str_cov (str.) – the name of covariance function.
  • prior_mu_train (numpy.ndarray) – the prior values computed by get_prior_mu(). Shape: (n, 1).
  • fix_noise (bool., optional) – flag for fixing a noise.
  • use_cholesky (bool., optional) – flag for using a cholesky decomposition.
  • use_gradient (bool., optional) – flag for computing and returning gradients of negative log marginal likelihood.
  • debug (bool., optional) – flag for printing log messages.
Returns:

negative log marginal likelihood, or (negative log marginal likelihood, gradients of the likelihood).

Return type:

float, or tuple of (float, float)

Raises:

AssertionError

bayeso.gp.gp_scipy.neg_log_pseudo_l_loocv(X_train: numpy.ndarray, Y_train: numpy.ndarray, hyps: numpy.ndarray, str_cov: str, prior_mu_train: numpy.ndarray, fix_noise: bool = True, debug: bool = False) → float

It computes a negative log pseudo-likelihood using leave-one-out cross-validation.

Parameters:
  • X_train (numpy.ndarray) – inputs. Shape: (n, d) or (n, m, d).
  • Y_train (numpy.ndarray) – outputs. Shape: (n, 1).
  • hyps (numpy.ndarray) – hyperparameters for Gaussian process. Shape: (h, ).
  • str_cov (str.) – the name of covariance function.
  • prior_mu_train (numpy.ndarray) – the prior values computed by get_prior_mu(). Shape: (n, 1).
  • fix_noise (bool., optional) – flag for fixing a noise.
  • debug (bool., optional) – flag for printing log messages.
Returns:

negative log pseudo-likelihood.

Return type:

float

Raises:

AssertionError