Skip to content

update the default value of jitter to JITTER_DEFAULT #6055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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