Gaussian Linear Model¶
Routine for polynomial regression (Gaussian Linear Model)
-
class
gaussianlinear.
GLM
(theta: numpy.ndarray, y: numpy.ndarray, order: int = 2, var: float = 1e-05, x_trans: bool = False, y_trans: bool = False, use_mean: bool = True)[source]¶ Bases:
object
Gaussian Linear Model (GLM) class for polynomial regression
-
compute_basis
(test_point: numpy.ndarray = None) → numpy.ndarray[source]¶ Compute the input basis functions
- Param
test_point (np.ndarray: optional) : if a test point is provided, phi_star is calculated
- Returns
phi or phi_star (np.ndarray) : the basis functions
-
evidence
() → numpy.ndarray[source]¶ Calculates the log-evidence of the model
- Returns
log_evidence (np.ndarray) : the log evidence of the model
-
inv_noise_cov
() → numpy.ndarray[source]¶ Calculate the inverse of the noise covariance matrix
- Returns
mat_inv (np.ndarray) : inverse of the noise covariance
-
inv_prior_cov
() → numpy.ndarray[source]¶ Calculate the inverse of the prior covariance matrix
mat_inv (np.ndarray) : inverse of the prior covariance matrix (parametric part)
-
posterior_coefficients
() → Tuple[numpy.ndarray, numpy.ndarray][source]¶ Calculate the posterior coefficients
beta_bar (np.ndarray) : mean posterior
lambda_cap (np.ndarray) : covariance of the regression coefficients
-
prediction
(test_point: numpy.ndarray) → Tuple[numpy.ndarray, numpy.ndarray][source]¶ Given a test point, the prediction (mean and variance) will be computed
- Param
test_point (np.ndarray) : vector of test point in parameter space
- Returns
post_mean (np.ndarray) : mean of the posterior
- Returns
post_var (np.ndarray) : variance of the posterior
-
regression_prior
(mean: numpy.ndarray = None, cov: numpy.ndarray = None, lambda_cap: float = 1) → None[source]¶ Specify the regression prior (mean and covariance)
- Param
mean (np.ndarray) : default zeros
- Param
cov (np.ndarray) : default identity matrix
- Param
lambda_cap (float) : width of the prior covariance matrix (default 1)
-