bayeso.covariance¶
-
bayeso.covariance.
choose_fun_cov
(str_cov, is_grad=False)¶ It is for choosing a covariance function or a function for computing gradients of covariance function.
Parameters: - str_cov (str.) – the name of covariance function.
- is_grad (bool., optional) – flag for returning a function for the gradients
Returns: covariance function, or function for computing gradients of covariance function.
Return type: function
Raises: AssertionError
-
bayeso.covariance.
cov_main
(str_cov, X, Xs, hyps, same_X_Xs, jitter=1e-05)¶ It computes kernel matrix over X and Xs, where hyps is given.
Parameters: - str_cov (str.) – the name of covariance function.
- X (numpy.ndarray) – one inputs. Shape: (n, d).
- Xs (numpy.ndarray) – another inputs. Shape: (m, d).
- hyps (dict.) – dictionary of hyperparameters for covariance function.
- same_X_Xs (bool.) – flag for checking X and Xs are same.
- jitter (float, optional) – jitter for diagonal entries.
Returns: kernel matrix over X and Xs. Shape: (n, m).
Return type: numpy.ndarray
Raises: AssertionError, ValueError
-
bayeso.covariance.
cov_matern32
(X, Xs, lengthscales, signal)¶ It computes Matern 3/2 kernel over X and Xs, where lengthscales and signal are given.
Parameters: - X (numpy.ndarray) – inputs. Shape: (n, d).
- Xs (numpy.ndarray) – another inputs. Shape: (m, d).
- lengthscales (numpy.ndarray, or float) – length scales. Shape: (d, ) or ().
- signal (float) – coefficient for signal.
Returns: kernel values over X and Xs. Shape: (n, m).
Return type: numpy.ndarray
Raises: AssertionError
-
bayeso.covariance.
cov_matern52
(X, Xs, lengthscales, signal)¶ It computes Matern 5/2 kernel over X and Xs, where lengthscales and signal are given.
Parameters: - X (numpy.ndarray) – inputs. Shape: (n, d).
- Xs (numpy.ndarray) – another inputs. Shape: (m, d).
- lengthscales (numpy.ndarray, or float) – length scales. Shape: (d, ) or ().
- signal (float) – coefficient for signal.
Returns: kernel values over X and Xs. Shape: (n, m).
Return type: numpy.ndarray
Raises: AssertionError
-
bayeso.covariance.
cov_se
(X, Xs, lengthscales, signal)¶ It computes squared exponential kernel over X and Xs, where lengthscales and signal are given.
Parameters: - X (numpy.ndarray) – inputs. Shape: (n, d).
- Xs (numpy.ndarray) – another inputs. Shape: (m, d).
- lengthscales (numpy.ndarray, or float) – length scales. Shape: (d, ) or ().
- signal (float) – coefficient for signal.
Returns: kernel values over X and Xs. Shape: (n, m).
Return type: numpy.ndarray
Raises: AssertionError
-
bayeso.covariance.
cov_set
(str_cov, X, Xs, lengthscales, signal)¶ It computes set kernel matrix over X and Xs, where lengthscales and signal are given.
Parameters: - str_cov (str.) – the name of covariance function.
- X (numpy.ndarray) – one inputs. Shape: (n, m, d).
- Xs (numpy.ndarray) – another inputs. Shape: (l, m, d).
- lengthscales (numpy.ndarray, or float) – length scales. Shape: (d, ) or ().
- signal (float) – coefficient for signal.
Returns: set kernel matrix over X and Xs. Shape: (n, l).
Return type: numpy.ndarray
Raises: AssertionError
-
bayeso.covariance.
grad_cov_main
(str_cov, X, Xs, hyps, is_fixed_noise, same_X_Xs=True, jitter=1e-05)¶ It computes gradients of kernel matrix over hyperparameters, where hyps is given.
Parameters: - str_cov (str.) – the name of covariance function.
- X (numpy.ndarray) – one inputs. Shape: (n, d).
- Xs (numpy.ndarray) – another inputs. Shape: (m, d).
- hyps (dict.) – dictionary of hyperparameters for covariance function.
- is_fixed_noise (bool.) – flag for fixing a noise.
- same_X_Xs (bool., optional) – flag for checking X and Xs are same.
- jitter (float, optional) – jitter for diagonal entries.
Returns: gradient matrix over hyperparameters. Shape: (n, m, l) where l is the number of hyperparameters.
Return type: numpy.ndarray
Raises: AssertionError
-
bayeso.covariance.
grad_cov_matern32
(cov_, X, Xs, hyps, num_hyps, is_fixed_noise)¶ It computes gradients of Matern 3/2 kernel over X and Xs, where hyps is given.
Parameters: - cov (numpy.ndarray) – covariance matrix. Shape: (n, m).
- X (numpy.ndarray) – one inputs. Shape: (n, d).
- Xs (numpy.ndarray) – another inputs. Shape: (m, d).
- hyps (dict.) – dictionary of hyperparameters for covariance function.
- num_hyps (int.) – the number of hyperparameters == l.
- is_fixed_noise (bool.) – flag for fixing a noise.
Returns: gradient matrix over hyperparameters. Shape: (n, m, l).
Return type: numpy.ndarray
Raises: AssertionError
-
bayeso.covariance.
grad_cov_matern52
(cov_, X, Xs, hyps, num_hyps, is_fixed_noise)¶ It computes gradients of Matern 5/2 kernel over X and Xs, where hyps is given.
Parameters: - cov (numpy.ndarray) – covariance matrix. Shape: (n, m).
- X (numpy.ndarray) – one inputs. Shape: (n, d).
- Xs (numpy.ndarray) – another inputs. Shape: (m, d).
- hyps (dict.) – dictionary of hyperparameters for covariance function.
- num_hyps (int.) – the number of hyperparameters == l.
- is_fixed_noise (bool.) – flag for fixing a noise.
Returns: gradient matrix over hyperparameters. Shape: (n, m, l).
Return type: numpy.ndarray
Raises: AssertionError
-
bayeso.covariance.
grad_cov_se
(cov_, X, Xs, hyps, num_hyps, is_fixed_noise)¶ It computes gradients of squared exponential kernel over X and Xs, where hyps is given.
Parameters: - cov (numpy.ndarray) – covariance matrix. Shape: (n, m).
- X (numpy.ndarray) – one inputs. Shape: (n, d).
- Xs (numpy.ndarray) – another inputs. Shape: (m, d).
- hyps (dict.) – dictionary of hyperparameters for covariance function.
- num_hyps (int.) – the number of hyperparameters == l.
- is_fixed_noise (bool.) – flag for fixing a noise.
Returns: gradient matrix over hyperparameters. Shape: (n, m, l).
Return type: numpy.ndarray
Raises: AssertionError