queens.models.surrogate_models.utils package#

Submodules#

queens.models.surrogate_models.utils.kernel_utils_jitted module#

Collection of jitted kernel objects for a GP.

grad_log_evidence_matern_3_2(param_vec, y_train_vec, x_train_vec, k_mat_inv, partial_derivatives_hyper_params_lst)[source]#

Calculate gradient of log-evidence for Matern 3/2 kernel.

Gradient of the log evidence function of the GP w.r.t. the variational hyper-parameters. The latter might be a transformed representation of the actual hyper-parameters.

Parameters:
  • param_vec (np.array) – Vector containing values of hyper-parameters. Note this is already used here in some of the other input values are computed beforehand and stored as attributes.

  • y_train_vec (np.array) – Output training vector of the GP

  • x_train_vec (np.array) – Input training vector for the GP

  • k_mat_inv (np.array) – Current inverse of the GP covariance matrix

  • partial_derivatives_hyper_params_lst (lst) – Partial derivatives of the log evidence w.r.t the hyper-parameters

Returns:

grad (np.array) – Gradient vector of the evidence w.r.t. the parameterization of the hyper-parameters

grad_log_evidence_squared_exponential(param_vec, y_train_vec, x_train_vec, k_mat_inv, partial_derivatives_hyper_params_lst)[source]#

Calculate gradient of log-evidence.

Gradient of the log evidence function of the GP w.r.t. the variational hyper-parameters. The latter might be a transformed representation of the actual hyper-parameters. The evidence is based on the squared exponential covariance function.

Parameters:
  • param_vec (np.array) – Vector containing values of hyper-parameters. Note this is already used here in some of the other input values are computed beforehand and stored as attributes.

  • y_train_vec (np.array) – Output training vector of the GP

  • x_train_vec (np.array) – Input training vector for the GP

  • k_mat_inv (np.array) – Current inverse of the GP covariance matrix

  • partial_derivatives_hyper_params_lst (lst) – Partial derivatives of the log evidence w.r.t the hyper-parameters

Returns:

grad (np.array) – Gradient vector of the evidence w.r.t. the parameterization of the hyper-parameters

grad_posterior_mean_matern_3_2(*_args)[source]#

Calculate gradient of posterior mean for Matern 3/2 kernel.

grad_posterior_mean_squared_exponential(k_mat_inv, x_test_mat, x_train_mat, y_train_vec, hyper_param_lst)[source]#

Jit the gradient of the posterior mean function of the GP.

The mean function is based on the squared exponential covariance function.

Parameters:
  • k_mat_inv (np.array) – Inverse of the assembled covariance matrix

  • x_test_mat (np.array) – Testing input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • x_train_mat (np.array) – Training input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • y_train_vec (np.array) – Training outputs for the GP. Column vector where rows correspond to different samples.

  • hyper_param_lst (lst) – List with the hyper-parameters of the kernel

Returns:

grad_mu_mat (np.array) – Gradient of the posterior mean vector (along columns) of the Gaussian Process evaluated at each x_test_vec (row-wise)

grad_posterior_var_matern_3_2(*_args)[source]#

Calculate gradient of posterior variance for Matern 3/2 kernel.

grad_posterior_var_squared_exponential(k_mat_inv, x_test_mat, x_train_mat, hyper_param_lst)[source]#

Jit the gradient of the posterior variance function.

The posterior is based on the squared exponential covariance function.

Parameters:
  • k_mat_inv (np.array) – Inverse of the assembled covariance matrix

  • x_test_mat (np.array) – Testing input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • x_train_mat (np.array) – Training input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • hyper_param_lst (lst) – List with the hyper-parameters of the kernel

Returns:

grad_posterior_variance (np.array) – Gradient of the posterior variance of the GP evaluated at the testing points x_test_vec

matern_3_2(x_train_mat, hyper_param_lst)[source]#

Jit the kernel for the Matern 3/2 function.

Also compute/pre-compile necessary derivatives for finding the MAP estimate of the GP. The covariance function here is the squared exponential covariance function.

Parameters:
  • x_train_mat (np.array) – Training input points for the GP. Row-wise samples are stored, different columns correspond to different input dimensions.

  • hyper_param_lst (lst) – List with the hyper-parameters for the kernel

Returns:
  • k_mat (np.array) – Assembled covariance matrix of the GP

  • k_mat_inv (np.array) – Inverse of the assembled covariance matrix

  • cholesky_k_mat (np.array) – Lower cholesky decomposition of the covariance matrix

  • partial_derivatives_hyper_params_lst (lst) – List with partial derivatives of the evidence w.r.t. the hyper-parameters

posterior_mean_matern_3_2(k_mat_inv, x_test_mat, x_train_mat, y_train_vec, hyper_param_lst)[source]#

Jit the posterior mean function of the Gaussian Process.

The mean function is based on the Matern 3/2 covariance function.

Parameters:
  • k_mat_inv (np.array) – Inverse of the assembled covariance matrix

  • x_test_mat (np.array) – Testing input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • x_train_mat (np.array) – Training input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • y_train_vec (np.array) – Training outputs for the GP. Column vector where rows correspond to different samples.

  • hyper_param_lst (lst) – List with the hyper-parameters of the kernel

Returns:

mu_vec (np.array) – Posterior mean vector of the Gaussian Process evaluated at x_test_vec

posterior_mean_squared_exponential(k_mat_inv, x_test_mat, x_train_mat, y_train_vec, hyper_param_lst)[source]#

Jit the posterior mean function of the Gaussian Process.

The mean function is based on the squared exponential covariance function.

Parameters:
  • k_mat_inv (np.array) – Inverse of the assembled covariance matrix

  • x_test_mat (np.array) – Testing input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • x_train_mat (np.array) – Training input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • y_train_vec (np.array) – Training outputs for the GP. Column vector where rows correspond to different samples.

  • hyper_param_lst (lst) – List with the hyper-parameters of the kernel

Returns:

mu_vec (np.array) – Posterior mean vector of the Gaussian Process evaluated at x_test_vec

posterior_var_matern_3_2(k_mat_inv, x_test_mat, x_train_mat, hyper_param_lst, support)[source]#

Jit the posterior variance function of the Gaussian Process.

The posterior is based on the Matern 3/2 kernel.

Parameters:
  • k_mat_inv (np.array) – Inverse of the assembled covariance matrix

  • x_test_mat (np.array) – Testing input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • x_train_mat (np.array) – Training input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • hyper_param_lst (lst) – List with the hyper-parameters of the kernel

  • support (str) – Support type for the posterior distribution. For ‘y’ the posterior is computed w.r.t. the output data; For ‘f’ the GP is computed w.r.t. the latent function f.

Returns:

posterior_variance_vec (np.array) – Posterior variance vector of the GP evaluated at the testing points x_test_vec

posterior_var_squared_exponential(k_mat_inv, x_test_mat, x_train_mat, hyper_param_lst, support)[source]#

Jit the posterior variance function of the Gaussian Process.

The posterior is based on the squared exponential covariance function.

Parameters:
  • k_mat_inv (np.array) – Inverse of the assembled covariance matrix

  • x_test_mat (np.array) – Testing input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • x_train_mat (np.array) – Training input points for the GP. Individual samples row-wise, columns correspond to different dimensions.

  • hyper_param_lst (lst) – List with the hyper-parameters of the kernel

  • support (str) – Support type for the posterior distribution. For ‘y’ the posterior is computed w.r.t. the output data; For ‘f’ the GP is computed w.r.t. the latent function f.

Returns:

posterior_variance_vec (np.array) – Posterior variance vector of the GP evaluated at the testing points x_test_vec

squared_exponential(x_train_mat, hyper_param_lst)[source]#

Jit the kernel for squared exponential covariance function.

Also compute/pre-compile necessary derivatives for finding the MAP estimate of the GP. The covariance function here is the squared exponential covariance function.

Parameters:
  • x_train_mat (np.array) – Training input points for the GP. Row-wise samples are stored, different columns correspond to different input dimensions.

  • hyper_param_lst (lst) – List with the hyper-parameters for the kernel

Returns:
  • k_mat (np.array) – Assembled covariance matrix of the GP

  • k_mat_inv (np.array) – Inverse of the assembled covariance matrix

  • cholesky_k_mat (np.array) – Lower cholesky decomposition of the covariance matrix

  • partial_derivatives_hyper_params_lst (lst) – List with partial derivatives of the evidence w.r.t. the hyper-parameters