Skip to content

Commit

Permalink
update the default value of jitter to JITTER_DEFAULT
Browse files Browse the repository at this point in the history
  • Loading branch information
danhphan committed Aug 18, 2022
1 parent b9c829a commit e5504ed
Showing 1 changed file with 32 additions and 25 deletions.
57 changes: 32 additions & 25 deletions pymc/gp/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def prior(self, name, X, reparameterize=True, jitter=JITTER_DEFAULT, **kwargs):
variable by the Cholesky factor of the covariance matrix.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. Default value is 1e-6.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to distribution constructor.
"""
Expand Down Expand Up @@ -196,7 +196,7 @@ def _build_conditional(self, Xnew, X, f, cov_total, mean_total, jitter):
cov = Kss - at.dot(at.transpose(A), A)
return mu, cov

def conditional(self, name, Xnew, given=None, jitter=0.0, **kwargs):
def conditional(self, name, Xnew, given=None, jitter=JITTER_DEFAULT, **kwargs):
R"""
Returns the conditional distribution evaluated over new input
locations `Xnew`.
Expand All @@ -223,8 +223,7 @@ def conditional(self, name, Xnew, given=None, jitter=0.0, **kwargs):
models in PyMC for more information.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. For conditionals
the default value is 0.0.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to `MvNormal` distribution
constructor.
Expand Down Expand Up @@ -324,7 +323,7 @@ def _build_conditional(self, Xnew, X, f, jitter):
covT = (self.nu + beta - 2) / (nu2 - 2) * cov
return nu2, mu, covT

def conditional(self, name, Xnew, jitter=0.0, **kwargs):
def conditional(self, name, Xnew, jitter=JITTER_DEFAULT, **kwargs):
R"""
Returns the conditional distribution evaluated over new input
locations `Xnew`.
Expand All @@ -341,8 +340,7 @@ def conditional(self, name, Xnew, jitter=0.0, **kwargs):
Function input values.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. For conditionals
the default value is 0.0.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to `MvNormal` distribution
constructor.
Expand Down Expand Up @@ -407,7 +405,9 @@ def _build_marginal_likelihood(self, X, noise, jitter):
cov = Kxx + Knx
return mu, stabilize(cov, jitter)

def marginal_likelihood(self, name, X, y, noise, jitter=0.0, is_observed=True, **kwargs):
def marginal_likelihood(
self, name, X, y, noise, jitter=JITTER_DEFAULT, is_observed=True, **kwargs
):
R"""
Returns the marginal likelihood distribution, given the input
locations `X` and the data `y`.
Expand All @@ -433,7 +433,7 @@ def marginal_likelihood(self, name, X, y, noise, jitter=0.0, is_observed=True, *
non-white noise.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. Default value is 0.0.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to `MvNormal` distribution
constructor.
Expand Down Expand Up @@ -497,7 +497,9 @@ def _build_conditional(
cov += noise(Xnew)
return mu, cov if pred_noise else stabilize(cov, jitter)

def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kwargs):
def conditional(
self, name, Xnew, pred_noise=False, given=None, jitter=JITTER_DEFAULT, **kwargs
):
R"""
Returns the conditional distribution evaluated over new input
locations `Xnew`.
Expand Down Expand Up @@ -527,8 +529,7 @@ def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kw
models in PyMC for more information.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. For conditionals
the default value is 0.0.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to `MvNormal` distribution
constructor.
Expand All @@ -539,7 +540,14 @@ def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kw
return pm.MvNormal(name, mu=mu, cov=cov, **kwargs)

def predict(
self, Xnew, point=None, diag=False, pred_noise=False, given=None, jitter=0.0, model=None
self,
Xnew,
point=None,
diag=False,
pred_noise=False,
given=None,
jitter=JITTER_DEFAULT,
model=None,
):
R"""
Return the mean vector and covariance matrix of the conditional
Expand All @@ -563,15 +571,14 @@ def predict(
Same as `conditional` method.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. For conditionals
the default value is 0.0.
covariance matrices to ensure numerical stability.
"""
if given is None:
given = {}
mu, cov = self._predict_at(Xnew, diag, pred_noise, given, jitter)
return replace_with_values([mu, cov], replacements=point, model=model)

def _predict_at(self, Xnew, diag=False, pred_noise=False, given=None, jitter=0.0):
def _predict_at(self, Xnew, diag=False, pred_noise=False, given=None, jitter=JITTER_DEFAULT):
R"""
Return the mean vector and covariance matrix of the conditional
distribution as symbolic variables.
Expand Down Expand Up @@ -712,7 +719,7 @@ def _build_marginal_likelihood_logp(self, y, X, Xu, sigma, jitter):
return -1.0 * (constant + logdet + quadratic + trace)

def marginal_likelihood(
self, name, X, Xu, y, noise=None, is_observed=True, jitter=0.0, **kwargs
self, name, X, Xu, y, noise=None, is_observed=True, jitter=JITTER_DEFAULT, **kwargs
):
R"""
Returns the approximate marginal likelihood distribution, given the input
Expand All @@ -738,7 +745,7 @@ def marginal_likelihood(
Default is `True`.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. Default value is 0.0.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to `MvNormal` distribution
constructor.
Expand Down Expand Up @@ -836,7 +843,9 @@ def _get_given_vals(self, given):
X, Xu, y, sigma = self.X, self.Xu, self.y, self.sigma
return X, Xu, y, sigma, cov_total, mean_total

def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kwargs):
def conditional(
self, name, Xnew, pred_noise=False, given=None, jitter=JITTER_DEFAULT, **kwargs
):
R"""
Returns the approximate conditional distribution of the GP evaluated over
new input locations `Xnew`.
Expand All @@ -857,8 +866,7 @@ def conditional(self, name, Xnew, pred_noise=False, given=None, jitter=0.0, **kw
models in PyMC for more information.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. For conditionals
the default value is 0.0.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to `MvNormal` distribution
constructor.
Expand Down Expand Up @@ -968,7 +976,7 @@ def prior(self, name, Xs, jitter=JITTER_DEFAULT, **kwargs):
`cartesian(*Xs)`.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. Default value is 1e-6.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to the `KroneckerNormal`
distribution constructor.
Expand Down Expand Up @@ -998,7 +1006,7 @@ def _build_conditional(self, Xnew, jitter):
cov = stabilize(Kss - at.dot(at.transpose(A), A), jitter)
return mu, cov

def conditional(self, name, Xnew, jitter=0.0, **kwargs):
def conditional(self, name, Xnew, jitter=JITTER_DEFAULT, **kwargs):
"""
Returns the conditional distribution evaluated over new input
locations `Xnew`.
Expand Down Expand Up @@ -1027,8 +1035,7 @@ def conditional(self, name, Xnew, jitter=0.0, **kwargs):
vector with shape `(n, 1)`.
jitter: scalar
A small correction added to the diagonal of positive semi-definite
covariance matrices to ensure numerical stability. For conditionals
the default value is 0.0.
covariance matrices to ensure numerical stability.
**kwargs
Extra keyword arguments that are passed to `MvNormal` distribution
constructor.
Expand Down

0 comments on commit e5504ed

Please sign in to comment.