bayeso.tp.tp
It defines Student-\(t\) process regression.
- bayeso.tp.tp.predict_with_cov(X_train: ndarray, Y_train: ndarray, X_test: ndarray, cov_X_X: ndarray, inv_cov_X_X: ndarray, hyps: dict, str_cov: str = 'matern52', prior_mu: Callable | None = None, debug: bool = False) Tuple[float, ndarray, ndarray, ndarray]
This function returns degree of freedom, posterior mean, posterior standard variance, and posterior covariance functions over X_test, computed by Student-$t$ 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 Student-$t$ 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 degree of freedom, posterior mean function over X_test, posterior standrad variance function over X_test, and posterior covariance matrix over X_test. Shape: ((), (l, 1), (l, 1), (l, l)).
- Return type:
tuple of (float, numpy.ndarray, numpy.ndarray, numpy.ndarray)
- Raises:
AssertionError
- bayeso.tp.tp.predict_with_hyps(X_train: ndarray, Y_train: ndarray, X_test: ndarray, hyps: dict, str_cov: str = 'matern52', prior_mu: Callable | None = None, debug: bool = False) Tuple[float, ndarray, ndarray, ndarray]
This function returns degree of freedom, posterior mean, posterior standard variance, and posterior covariance functions over X_test, computed by Student-$t$ 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 Student-$t$ 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 degree of freedom, posterior mean function over X_test, posterior standrad variance function over X_test, and posterior covariance matrix over X_test. Shape: ((), (l, 1), (l, 1), (l, l)).
- Return type:
tuple of (float, numpy.ndarray, numpy.ndarray, numpy.ndarray)
- Raises:
AssertionError
- bayeso.tp.tp.predict_with_optimized_hyps(X_train: ndarray, Y_train: ndarray, X_test: ndarray, str_cov: str = 'matern52', str_optimizer_method: str = 'SLSQP', prior_mu: Callable | None = None, fix_noise: float = True, debug: bool = False) Tuple[float, ndarray, ndarray, ndarray]
This function returns degree of freedom, posterior mean, posterior standard variance, and posterior covariance functions over X_test, computed by the Student-$t$ 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 degree of freedom, posterior mean function over X_test, posterior standrad variance function over X_test, and posterior covariance matrix over X_test. Shape: ((), (l, 1), (l, 1), (l, l)).
- Return type:
tuple of (float, numpy.ndarray, numpy.ndarray, numpy.ndarray)
- Raises:
AssertionError
- bayeso.tp.tp.sample_functions(nu: float, mu: ndarray, Sigma: ndarray, num_samples: int = 1) ndarray
It samples num_samples functions from multivariate Student-$t$ distribution (nu, 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