mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-07-11 16:22:13 +02:00
Merge pull request #1101 from janmayer/fix_invalid_escape_sequence
Fix invalid escape sequence
This commit is contained in:
commit
1fcb40845d
52 changed files with 394 additions and 393 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
* fix invalid escape sequence #1011 [janmayer]
|
||||||
|
|
||||||
## v1.13.2 (2024-07-21)
|
## v1.13.2 (2024-07-21)
|
||||||
* update string checks in initialization method for latent variable and put `empirical_samples` init-method on a deprecation path
|
* update string checks in initialization method for latent variable and put `empirical_samples` init-method on a deprecation path
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ class GP(Model):
|
||||||
# Make sure to name this variable and the predict functions will "just work"
|
# Make sure to name this variable and the predict functions will "just work"
|
||||||
# In maths the predictive variable is:
|
# In maths the predictive variable is:
|
||||||
# K_{xx} - K_{xp}W_{pp}^{-1}K_{px}
|
# K_{xx} - K_{xp}W_{pp}^{-1}K_{px}
|
||||||
# W_{pp} := \texttt{Woodbury inv}
|
# W_{pp} := \\texttt{Woodbury inv}
|
||||||
# p := _predictive_variable
|
# p := _predictive_variable
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -283,7 +283,7 @@ class GP(Model):
|
||||||
|
|
||||||
def log_likelihood(self):
|
def log_likelihood(self):
|
||||||
"""
|
"""
|
||||||
The log marginal likelihood of the model, :math:`p(\mathbf{y})`, this is the objective function of the model being optimised
|
The log marginal likelihood of the model, :math:`p(\\mathbf{y})`, this is the objective function of the model being optimised
|
||||||
"""
|
"""
|
||||||
return self._log_marginal_likelihood
|
return self._log_marginal_likelihood
|
||||||
|
|
||||||
|
|
@ -296,9 +296,9 @@ class GP(Model):
|
||||||
diagonal of the covariance is returned.
|
diagonal of the covariance is returned.
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
p(f*|X*, X, Y) = \int^{\inf}_{\inf} p(f*|f,X*)p(f|X,Y) df
|
p(f*|X*, X, Y) = \\int^{\\inf}_{\\inf} p(f*|f,X*)p(f|X,Y) df
|
||||||
= N(f*| K_{x*x}(K_{xx} + \Sigma)^{-1}Y, K_{x*x*} - K_{xx*}(K_{xx} + \Sigma)^{-1}K_{xx*}
|
= N(f*| K_{x*x}(K_{xx} + \\Sigma)^{-1}Y, K_{x*x*} - K_{xx*}(K_{xx} + \\Sigma)^{-1}K_{xx*}
|
||||||
\Sigma := \texttt{Likelihood.variance / Approximate likelihood covariance}
|
\\Sigma := \\texttt{Likelihood.variance / Approximate likelihood covariance}
|
||||||
"""
|
"""
|
||||||
mu, var = self.posterior._raw_predict(kern=self.kern if kern is None else kern, Xnew=Xnew, pred_var=self._predictive_variable, full_cov=full_cov)
|
mu, var = self.posterior._raw_predict(kern=self.kern if kern is None else kern, Xnew=Xnew, pred_var=self._predictive_variable, full_cov=full_cov)
|
||||||
if self.mean_function is not None:
|
if self.mean_function is not None:
|
||||||
|
|
@ -702,7 +702,7 @@ class GP(Model):
|
||||||
Calculation of the log predictive density
|
Calculation of the log predictive density
|
||||||
|
|
||||||
.. math:
|
.. math:
|
||||||
p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\mu_{*}\\sigma^{2}_{*})
|
p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\\mu_{*}\\sigma^{2}_{*})
|
||||||
|
|
||||||
:param x_test: test locations (x_{*})
|
:param x_test: test locations (x_{*})
|
||||||
:type x_test: (Nx1) array
|
:type x_test: (Nx1) array
|
||||||
|
|
@ -718,7 +718,7 @@ class GP(Model):
|
||||||
Calculation of the log predictive density by sampling
|
Calculation of the log predictive density by sampling
|
||||||
|
|
||||||
.. math:
|
.. math:
|
||||||
p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\mu_{*}\\sigma^{2}_{*})
|
p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\\mu_{*}\\sigma^{2}_{*})
|
||||||
|
|
||||||
:param x_test: test locations (x_{*})
|
:param x_test: test locations (x_{*})
|
||||||
:type x_test: (Nx1) array
|
:type x_test: (Nx1) array
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,7 @@ class Symbolic_core():
|
||||||
def _display_expression(self, keys, user_substitutes={}):
|
def _display_expression(self, keys, user_substitutes={}):
|
||||||
"""Helper function for human friendly display of the symbolic components."""
|
"""Helper function for human friendly display of the symbolic components."""
|
||||||
# Create some pretty maths symbols for the display.
|
# Create some pretty maths symbols for the display.
|
||||||
sigma, alpha, nu, omega, l, variance = sym.var('\sigma, \alpha, \nu, \omega, \ell, \sigma^2')
|
sigma, alpha, nu, omega, l, variance = sym.var(r'\sigma, \alpha, \nu, \omega, \ell, \sigma^2')
|
||||||
substitutes = {'scale': sigma, 'shape': alpha, 'lengthscale': l, 'variance': variance}
|
substitutes = {'scale': sigma, 'shape': alpha, 'lengthscale': l, 'variance': variance}
|
||||||
substitutes.update(user_substitutes)
|
substitutes.update(user_substitutes)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,10 +134,10 @@ class posteriorParams(posteriorParamsBase):
|
||||||
B = np.eye(num_data) + Sroot_tilde_K * tau_tilde_root[None,:]
|
B = np.eye(num_data) + Sroot_tilde_K * tau_tilde_root[None,:]
|
||||||
L = jitchol(B)
|
L = jitchol(B)
|
||||||
V, _ = dtrtrs(L, Sroot_tilde_K, lower=1)
|
V, _ = dtrtrs(L, Sroot_tilde_K, lower=1)
|
||||||
Sigma = K - np.dot(V.T,V) #K - KS^(1/2)BS^(1/2)K = (K^(-1) + \Sigma^(-1))^(-1)
|
Sigma = K - np.dot(V.T,V) #K - KS^(1/2)BS^(1/2)K = (K^(-1) + \\Sigma^(-1))^(-1)
|
||||||
|
|
||||||
aux_alpha , _ = dpotrs(L, tau_tilde_root * (np.dot(K, ga_approx.v) + mean_prior), lower=1)
|
aux_alpha , _ = dpotrs(L, tau_tilde_root * (np.dot(K, ga_approx.v) + mean_prior), lower=1)
|
||||||
alpha = ga_approx.v - tau_tilde_root * aux_alpha #(K + Sigma^(\tilde))^(-1) (/mu^(/tilde) - /mu_p)
|
alpha = ga_approx.v - tau_tilde_root * aux_alpha #(K + Sigma^(\\tilde))^(-1) (/mu^(/tilde) - /mu_p)
|
||||||
mu = np.dot(K, alpha) + mean_prior
|
mu = np.dot(K, alpha) + mean_prior
|
||||||
|
|
||||||
return posteriorParams(mu=mu, Sigma=Sigma, L=L)
|
return posteriorParams(mu=mu, Sigma=Sigma, L=L)
|
||||||
|
|
@ -151,8 +151,8 @@ class posteriorParamsDTC(posteriorParamsBase):
|
||||||
DSYR(LLT,Kmn[:,i].copy(),delta_tau)
|
DSYR(LLT,Kmn[:,i].copy(),delta_tau)
|
||||||
L = jitchol(LLT)
|
L = jitchol(LLT)
|
||||||
V,info = dtrtrs(L,Kmn,lower=1)
|
V,info = dtrtrs(L,Kmn,lower=1)
|
||||||
self.Sigma_diag = np.maximum(np.sum(V*V,-2), np.finfo(float).eps) #diag(K_nm (L L^\top)^(-1)) K_mn
|
self.Sigma_diag = np.maximum(np.sum(V*V,-2), np.finfo(float).eps) #diag(K_nm (L L^\\top)^(-1)) K_mn
|
||||||
si = np.sum(V.T*V[:,i],-1) #(V V^\top)[:,i]
|
si = np.sum(V.T*V[:,i],-1) #(V V^\\top)[:,i]
|
||||||
self.mu += (delta_v-delta_tau*self.mu[i])*si
|
self.mu += (delta_v-delta_tau*self.mu[i])*si
|
||||||
#mu = np.dot(Sigma, v_tilde)
|
#mu = np.dot(Sigma, v_tilde)
|
||||||
|
|
||||||
|
|
@ -391,11 +391,11 @@ class EP(EPBase, ExactGaussianInference):
|
||||||
|
|
||||||
|
|
||||||
aux_alpha , _ = dpotrs(post_params.L, tau_tilde_root * (np.dot(K, ga_approx.v) + mean_prior), lower=1)
|
aux_alpha , _ = dpotrs(post_params.L, tau_tilde_root * (np.dot(K, ga_approx.v) + mean_prior), lower=1)
|
||||||
alpha = (ga_approx.v - tau_tilde_root * aux_alpha)[:,None] #(K + Sigma^(\tilde))^(-1) (/mu^(/tilde) - /mu_p)
|
alpha = (ga_approx.v - tau_tilde_root * aux_alpha)[:,None] #(K + Sigma^(\\tilde))^(-1) (/mu^(/tilde) - /mu_p)
|
||||||
|
|
||||||
LWi, _ = dtrtrs(post_params.L, np.diag(tau_tilde_root), lower=1)
|
LWi, _ = dtrtrs(post_params.L, np.diag(tau_tilde_root), lower=1)
|
||||||
Wi = np.dot(LWi.T,LWi)
|
Wi = np.dot(LWi.T,LWi)
|
||||||
symmetrify(Wi) #(K + Sigma^(\tilde))^(-1)
|
symmetrify(Wi) #(K + Sigma^(\\tilde))^(-1)
|
||||||
|
|
||||||
dL_dK = 0.5 * (tdot(alpha) - Wi)
|
dL_dK = 0.5 * (tdot(alpha) - Wi)
|
||||||
dL_dthetaL = likelihood.ep_gradients(Y, cav_params.tau, cav_params.v, np.diag(dL_dK), Y_metadata=Y_metadata, quad_mode='gh')
|
dL_dthetaL = likelihood.ep_gradients(Y, cav_params.tau, cav_params.v, np.diag(dL_dK), Y_metadata=Y_metadata, quad_mode='gh')
|
||||||
|
|
@ -530,7 +530,7 @@ class EPDTC(EPBase, VarDTC):
|
||||||
#initial values - Gaussian factors
|
#initial values - Gaussian factors
|
||||||
#Initial values - Posterior distribution parameters: q(f|X,Y) = N(f|mu,Sigma)
|
#Initial values - Posterior distribution parameters: q(f|X,Y) = N(f|mu,Sigma)
|
||||||
LLT0 = Kmm.copy()
|
LLT0 = Kmm.copy()
|
||||||
Lm = jitchol(LLT0) #K_m = L_m L_m^\top
|
Lm = jitchol(LLT0) #K_m = L_m L_m^\\top
|
||||||
Vm,info = dtrtrs(Lm, Kmn,lower=1)
|
Vm,info = dtrtrs(Lm, Kmn,lower=1)
|
||||||
# Lmi = dtrtri(Lm)
|
# Lmi = dtrtri(Lm)
|
||||||
# Kmmi = np.dot(Lmi.T,Lmi)
|
# Kmmi = np.dot(Lmi.T,Lmi)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class Laplace(LatentFunctionInference):
|
||||||
"""
|
"""
|
||||||
Laplace Approximation
|
Laplace Approximation
|
||||||
|
|
||||||
Find the moments \hat{f} and the hessian at this point
|
Find the moments \\hat{f} and the hessian at this point
|
||||||
(using Newton-Raphson) of the unnormalised posterior
|
(using Newton-Raphson) of the unnormalised posterior
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ log_2_pi = np.log(2*np.pi)
|
||||||
class PEP(LatentFunctionInference):
|
class PEP(LatentFunctionInference):
|
||||||
'''
|
'''
|
||||||
Sparse Gaussian processes using Power-Expectation Propagation
|
Sparse Gaussian processes using Power-Expectation Propagation
|
||||||
for regression: alpha \approx 0 gives VarDTC and alpha = 1 gives FITC
|
for regression: alpha \\approx 0 gives VarDTC and alpha = 1 gives FITC
|
||||||
|
|
||||||
Reference: A Unifying Framework for Sparse Gaussian Process Approximation using
|
Reference: A Unifying Framework for Sparse Gaussian Process Approximation using
|
||||||
Power Expectation Propagation, https://arxiv.org/abs/1605.07066
|
Power Expectation Propagation, https://arxiv.org/abs/1605.07066
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class Posterior(object):
|
||||||
Posterior mean
|
Posterior mean
|
||||||
$$
|
$$
|
||||||
K_{xx}v
|
K_{xx}v
|
||||||
v := \texttt{Woodbury vector}
|
v := \\texttt{Woodbury vector}
|
||||||
$$
|
$$
|
||||||
"""
|
"""
|
||||||
if self._mean is None:
|
if self._mean is None:
|
||||||
|
|
@ -95,7 +95,7 @@ class Posterior(object):
|
||||||
Posterior covariance
|
Posterior covariance
|
||||||
$$
|
$$
|
||||||
K_{xx} - K_{xx}W_{xx}^{-1}K_{xx}
|
K_{xx} - K_{xx}W_{xx}^{-1}K_{xx}
|
||||||
W_{xx} := \texttt{Woodbury inv}
|
W_{xx} := \\texttt{Woodbury inv}
|
||||||
$$
|
$$
|
||||||
"""
|
"""
|
||||||
if self._covariance is None:
|
if self._covariance is None:
|
||||||
|
|
@ -146,8 +146,8 @@ class Posterior(object):
|
||||||
"""
|
"""
|
||||||
return $L_{W}$ where L is the lower triangular Cholesky decomposition of the Woodbury matrix
|
return $L_{W}$ where L is the lower triangular Cholesky decomposition of the Woodbury matrix
|
||||||
$$
|
$$
|
||||||
L_{W}L_{W}^{\top} = W^{-1}
|
L_{W}L_{W}^{\\top} = W^{-1}
|
||||||
W^{-1} := \texttt{Woodbury inv}
|
W^{-1} := \\texttt{Woodbury inv}
|
||||||
$$
|
$$
|
||||||
"""
|
"""
|
||||||
if self._woodbury_chol is None:
|
if self._woodbury_chol is None:
|
||||||
|
|
@ -178,8 +178,8 @@ class Posterior(object):
|
||||||
"""
|
"""
|
||||||
The inverse of the woodbury matrix, in the gaussian likelihood case it is defined as
|
The inverse of the woodbury matrix, in the gaussian likelihood case it is defined as
|
||||||
$$
|
$$
|
||||||
(K_{xx} + \Sigma_{xx})^{-1}
|
(K_{xx} + \\Sigma_{xx})^{-1}
|
||||||
\Sigma_{xx} := \texttt{Likelihood.variance / Approximate likelihood covariance}
|
\\Sigma_{xx} := \\texttt{Likelihood.variance / Approximate likelihood covariance}
|
||||||
$$
|
$$
|
||||||
"""
|
"""
|
||||||
if self._woodbury_inv is None:
|
if self._woodbury_inv is None:
|
||||||
|
|
@ -200,8 +200,8 @@ class Posterior(object):
|
||||||
"""
|
"""
|
||||||
Woodbury vector in the gaussian likelihood case only is defined as
|
Woodbury vector in the gaussian likelihood case only is defined as
|
||||||
$$
|
$$
|
||||||
(K_{xx} + \Sigma)^{-1}Y
|
(K_{xx} + \\Sigma)^{-1}Y
|
||||||
\Sigma := \texttt{Likelihood.variance / Approximate likelihood covariance}
|
\\Sigma := \\texttt{Likelihood.variance / Approximate likelihood covariance}
|
||||||
$$
|
$$
|
||||||
"""
|
"""
|
||||||
if self._woodbury_vector is None:
|
if self._woodbury_vector is None:
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@ class Coregionalize(Kern):
|
||||||
This covariance has the form:
|
This covariance has the form:
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\mathbf{B} = \mathbf{W}\mathbf{W}^\intercal + \mathrm{diag}(kappa)
|
\\mathbf{B} = \\mathbf{W}\\mathbf{W}^\\intercal + \\mathrm{diag}(kappa)
|
||||||
|
|
||||||
An intrinsic/linear coregionalization covariance function of the form:
|
An intrinsic/linear coregionalization covariance function of the form:
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
k_2(x, y)=\mathbf{B} k(x, y)
|
k_2(x, y)=\\mathbf{B} k(x, y)
|
||||||
|
|
||||||
it is obtained as the tensor product between a covariance function
|
it is obtained as the tensor product between a covariance function
|
||||||
k(x, y) and B.
|
k(x, y) and B.
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class EQ_ODE1(Kern):
|
||||||
|
|
||||||
This outputs of this kernel have the form
|
This outputs of this kernel have the form
|
||||||
.. math::
|
.. math::
|
||||||
\frac{\text{d}y_j}{\text{d}t} = \sum_{i=1}^R w_{j,i} u_i(t-\delta_j) - d_jy_j(t)
|
\\frac{\\text{d}y_j}{\\text{d}t} = \\sum_{i=1}^R w_{j,i} u_i(t-\\delta_j) - d_jy_j(t)
|
||||||
|
|
||||||
where :math:`R` is the rank of the system, :math:`w_{j,i}` is the sensitivity of the :math:`j`th output to the :math:`i`th latent function, :math:`d_j` is the decay rate of the :math:`j`th output and :math:`u_i(t)` are independent latent Gaussian processes goverened by an exponentiated quadratic covariance.
|
where :math:`R` is the rank of the system, :math:`w_{j,i}` is the sensitivity of the :math:`j`th output to the :math:`i`th latent function, :math:`d_j` is the decay rate of the :math:`j`th output and :math:`u_i(t)` are independent latent Gaussian processes goverened by an exponentiated quadratic covariance.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class EQ_ODE2(Kern):
|
||||||
|
|
||||||
This outputs of this kernel have the form
|
This outputs of this kernel have the form
|
||||||
.. math::
|
.. math::
|
||||||
\frac{\text{d}^2y_j(t)}{\text{d}^2t} + C_j\frac{\text{d}y_j(t)}{\text{d}t} + B_jy_j(t) = \sum_{i=1}^R w_{j,i} u_i(t)
|
\\frac{\\text{d}^2y_j(t)}{\\text{d}^2t} + C_j\\frac{\\text{d}y_j(t)}{\\text{d}t} + B_jy_j(t) = \\sum_{i=1}^R w_{j,i} u_i(t)
|
||||||
|
|
||||||
where :math:`R` is the rank of the system, :math:`w_{j,i}` is the sensitivity of the :math:`j`th output to the :math:`i`th latent function, :math:`d_j` is the decay rate of the :math:`j`th output and :math:`f_i(t)` and :math:`g_i(t)` are independent latent Gaussian processes goverened by an exponentiated quadratic covariance.
|
where :math:`R` is the rank of the system, :math:`w_{j,i}` is the sensitivity of the :math:`j`th output to the :math:`i`th latent function, :math:`d_j` is the decay rate of the :math:`j`th output and :math:`f_i(t)` and :math:`g_i(t)` are independent latent Gaussian processes goverened by an exponentiated quadratic covariance.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class GridRBF(GridKern):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r^2 \\bigg)
|
k(r) = \\sigma^2 \\exp \\bigg(- \\frac{1}{2} r^2 \\bigg)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
_support_GPU = True
|
_support_GPU = True
|
||||||
|
|
|
||||||
|
|
@ -146,25 +146,25 @@ class Kern(Parameterized):
|
||||||
def psi0(self, Z, variational_posterior):
|
def psi0(self, Z, variational_posterior):
|
||||||
"""
|
"""
|
||||||
.. math::
|
.. math::
|
||||||
\psi_0 = \sum_{i=0}^{n}E_{q(X)}[k(X_i, X_i)]
|
\\psi_0 = \\sum_{i=0}^{n}E_{q(X)}[k(X_i, X_i)]
|
||||||
"""
|
"""
|
||||||
return self.psicomp.psicomputations(self, Z, variational_posterior)[0]
|
return self.psicomp.psicomputations(self, Z, variational_posterior)[0]
|
||||||
def psi1(self, Z, variational_posterior):
|
def psi1(self, Z, variational_posterior):
|
||||||
"""
|
"""
|
||||||
.. math::
|
.. math::
|
||||||
\psi_1^{n,m} = E_{q(X)}[k(X_n, Z_m)]
|
\\psi_1^{n,m} = E_{q(X)}[k(X_n, Z_m)]
|
||||||
"""
|
"""
|
||||||
return self.psicomp.psicomputations(self, Z, variational_posterior)[1]
|
return self.psicomp.psicomputations(self, Z, variational_posterior)[1]
|
||||||
def psi2(self, Z, variational_posterior):
|
def psi2(self, Z, variational_posterior):
|
||||||
"""
|
"""
|
||||||
.. math::
|
.. math::
|
||||||
\psi_2^{m,m'} = \sum_{i=0}^{n}E_{q(X)}[ k(Z_m, X_i) k(X_i, Z_{m'})]
|
\\psi_2^{m,m'} = \\sum_{i=0}^{n}E_{q(X)}[ k(Z_m, X_i) k(X_i, Z_{m'})]
|
||||||
"""
|
"""
|
||||||
return self.psicomp.psicomputations(self, Z, variational_posterior, return_psi2_n=False)[2]
|
return self.psicomp.psicomputations(self, Z, variational_posterior, return_psi2_n=False)[2]
|
||||||
def psi2n(self, Z, variational_posterior):
|
def psi2n(self, Z, variational_posterior):
|
||||||
"""
|
"""
|
||||||
.. math::
|
.. math::
|
||||||
\psi_2^{n,m,m'} = E_{q(X)}[ k(Z_m, X_n) k(X_n, Z_{m'})]
|
\\psi_2^{n,m,m'} = E_{q(X)}[ k(Z_m, X_n) k(X_n, Z_{m'})]
|
||||||
|
|
||||||
Thus, we do not sum out n, compared to psi2
|
Thus, we do not sum out n, compared to psi2
|
||||||
"""
|
"""
|
||||||
|
|
@ -173,7 +173,7 @@ class Kern(Parameterized):
|
||||||
"""
|
"""
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
\\frac{\partial L}{\partial X} = \\frac{\partial L}{\partial K}\\frac{\partial K}{\partial X}
|
\\frac{\\partial L}{\\partial X} = \\frac{\\partial L}{\\partial K}\\frac{\\partial K}{\\partial X}
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
def gradients_X_X2(self, dL_dK, X, X2):
|
def gradients_X_X2(self, dL_dK, X, X2):
|
||||||
|
|
@ -182,7 +182,7 @@ class Kern(Parameterized):
|
||||||
"""
|
"""
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
\\frac{\partial^2 L}{\partial X\partial X_2} = \\frac{\partial L}{\partial K}\\frac{\partial^2 K}{\partial X\partial X_2}
|
\\frac{\\partial^2 L}{\\partial X\\partial X_2} = \\frac{\\partial L}{\\partial K}\\frac{\\partial^2 K}{\\partial X\\partial X_2}
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError("This is the second derivative of K wrt X and X2, and not implemented for this kernel")
|
raise NotImplementedError("This is the second derivative of K wrt X and X2, and not implemented for this kernel")
|
||||||
def gradients_XX_diag(self, dL_dKdiag, X, cov=True):
|
def gradients_XX_diag(self, dL_dKdiag, X, cov=True):
|
||||||
|
|
@ -216,9 +216,9 @@ class Kern(Parameterized):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
\\frac{\partial L}{\partial \\theta_i} & = \\frac{\partial L}{\partial \psi_0}\\frac{\partial \psi_0}{\partial \\theta_i}\\
|
\\frac{\\partial L}{\\partial \\theta_i} & = \\frac{\\partial L}{\\partial \\psi_0}\\frac{\\partial \\psi_0}{\\partial \\theta_i}\\
|
||||||
& \quad + \\frac{\partial L}{\partial \psi_1}\\frac{\partial \psi_1}{\partial \\theta_i}\\
|
& \\quad + \\frac{\\partial L}{\\partial \\psi_1}\\frac{\\partial \\psi_1}{\\partial \\theta_i}\\
|
||||||
& \quad + \\frac{\partial L}{\partial \psi_2}\\frac{\partial \psi_2}{\partial \\theta_i}
|
& \\quad + \\frac{\\partial L}{\\partial \\psi_2}\\frac{\\partial \\psi_2}{\\partial \\theta_i}
|
||||||
|
|
||||||
Thus, we push the different derivatives through the gradients of the psi
|
Thus, we push the different derivatives through the gradients of the psi
|
||||||
statistics. Be sure to set the gradients for all kernel
|
statistics. Be sure to set the gradients for all kernel
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,15 @@ class Linear(Kern):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \sum_{i=1}^{\\text{input_dim}} \sigma^2_i x_iy_i
|
k(x,y) = \\sum_{i=1}^{\\text{input_dim}} \\sigma^2_i x_iy_i
|
||||||
|
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param variances: the vector of variances :math:`\sigma^2_i`
|
:param variances: the vector of variances :math:`\\sigma^2_i`
|
||||||
:type variances: array or list of the appropriate size (or float if there
|
:type variances: array or list of the appropriate size (or float if there
|
||||||
is only one variance parameter)
|
is only one variance parameter)
|
||||||
:param ARD: Auto Relevance Determination. If False, the kernel has only one
|
:param ARD: Auto Relevance Determination. If False, the kernel has only one
|
||||||
variance parameter \sigma^2, otherwise there is one variance
|
variance parameter \\sigma^2, otherwise there is one variance
|
||||||
parameter per dimension.
|
parameter per dimension.
|
||||||
:type ARD: Boolean
|
:type ARD: Boolean
|
||||||
:rtype: kernel object
|
:rtype: kernel object
|
||||||
|
|
@ -121,7 +121,7 @@ class Linear(Kern):
|
||||||
the returned array is of shape [NxNxQxQ].
|
the returned array is of shape [NxNxQxQ].
|
||||||
|
|
||||||
..math:
|
..math:
|
||||||
\frac{\partial^2 K}{\partial X2 ^2} = - \frac{\partial^2 K}{\partial X\partial X2}
|
\\frac{\\partial^2 K}{\\partial X2 ^2} = - \\frac{\\partial^2 K}{\\partial X\\partial X2}
|
||||||
|
|
||||||
..returns:
|
..returns:
|
||||||
dL2_dXdX2: [NxMxQxQ] for X [NxQ] and X2[MxQ] (X2 is X if, X2 is None)
|
dL2_dXdX2: [NxMxQxQ] for X [NxQ] and X2[MxQ] (X2 is X if, X2 is None)
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ class MLP(Kern):
|
||||||
|
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param variance: the variance :math:`\sigma^2`
|
:param variance: the variance :math:`\\sigma^2`
|
||||||
:type variance: float
|
:type variance: float
|
||||||
:param weight_variance: the vector of the variances of the prior over input weights in the neural network :math:`\sigma^2_w`
|
:param weight_variance: the vector of the variances of the prior over input weights in the neural network :math:`\\sigma^2_w`
|
||||||
:type weight_variance: array or list of the appropriate size (or float if there is only one weight variance parameter)
|
:type weight_variance: array or list of the appropriate size (or float if there is only one weight variance parameter)
|
||||||
:param bias_variance: the variance of the prior over bias parameters :math:`\sigma^2_b`
|
:param bias_variance: the variance of the prior over bias parameters :math:`\\sigma^2_b`
|
||||||
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one weight variance parameter \sigma^2_w), otherwise there is one weight variance parameter per dimension.
|
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one weight variance parameter \\sigma^2_w), otherwise there is one weight variance parameter per dimension.
|
||||||
:type ARD: Boolean
|
:type ARD: Boolean
|
||||||
:rtype: Kernpart object
|
:rtype: Kernpart object
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class RBF(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r^2 \\bigg)
|
k(r) = \\sigma^2 \\exp \\bigg(- \\frac{1}{2} r^2 \\bigg)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
_support_GPU = True
|
_support_GPU = True
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class sde_Brownian(Brownian):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \sigma^2 min(x,y)
|
k(x,y) = \\sigma^2 min(x,y)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class sde_Linear(Linear):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \sum_{i=1}^{input dim} \sigma^2_i x_iy_i
|
k(x,y) = \\sum_{i=1}^{input dim} \\sigma^2_i x_iy_i
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, input_dim, X, variances=None, ARD=False, active_dims=None, name='linear'):
|
def __init__(self, input_dim, X, variances=None, ARD=False, active_dims=None, name='linear'):
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class sde_Matern32(Matern32):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 (1 + \sqrt{3} r) \exp(- \sqrt{3} r) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} }
|
k(r) = \\sigma^2 (1 + \\sqrt{3} r) \\exp(- \\sqrt{3} r) \\ \\ \\ \\ \\text{ where } r = \\sqrt{\\sum_{i=1}^{input dim} \\frac{(x_i-y_i)^2}{\\ell_i^2} }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def sde_update_gradient_full(self, gradients):
|
def sde_update_gradient_full(self, gradients):
|
||||||
|
|
@ -79,7 +79,7 @@ class sde_Matern52(Matern52):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 (1 + \sqrt{5} r + \frac{5}{3}r^2) \exp(- \sqrt{5} r) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} }
|
k(r) = \\sigma^2 (1 + \\sqrt{5} r + \\frac{5}{3}r^2) \\exp(- \\sqrt{5} r) \\ \\ \\ \\ \\text{ where } r = \\sqrt{\\sum_{i=1}^{input dim} \\frac{(x_i-y_i)^2}{\\ell_i^2} }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def sde_update_gradient_full(self, gradients):
|
def sde_update_gradient_full(self, gradients):
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ class sde_StdPeriodic(StdPeriodic):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \theta_1 \exp \left[ - \frac{1}{2} {}\sum_{i=1}^{input\_dim}
|
k(x,y) = \\theta_1 \\exp \\left[ - \\frac{1}{2} {}\\sum_{i=1}^{input\\_dim}
|
||||||
\left( \frac{\sin(\frac{\pi}{\lambda_i} (x_i - y_i) )}{l_i} \right)^2 \right] }
|
\\left( \\frac{\\sin(\\frac{\\pi}{\\lambda_i} (x_i - y_i) )}{l_i} \\right)^2 \\right] }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -177,7 +177,7 @@ def seriescoeff(m=6, lengthScale=1.0, magnSigma2=1.0, true_covariance=False):
|
||||||
Calculate the coefficients q_j^2 for the covariance function
|
Calculate the coefficients q_j^2 for the covariance function
|
||||||
approximation:
|
approximation:
|
||||||
|
|
||||||
k(\tau) = \sum_{j=0}^{+\infty} q_j^2 \cos(j\omega_0 \tau)
|
k(\\tau) = \\sum_{j=0}^{+\\infty} q_j^2 \\cos(j\\omega_0 \\tau)
|
||||||
|
|
||||||
Reference is:
|
Reference is:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class sde_White(White):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \alpha*\delta(x-y)
|
k(x,y) = \\alpha*\\delta(x-y)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -68,7 +68,7 @@ class sde_Bias(Bias):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \alpha
|
k(x,y) = \\alpha
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def sde_update_gradient_full(self, gradients):
|
def sde_update_gradient_full(self, gradients):
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class sde_RBF(RBF):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r^2 \\bigg) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} }
|
k(r) = \\sigma^2 \\exp \\bigg(- \\frac{1}{2} r^2 \\bigg) \\ \\ \\ \\ \\text{ where } r = \\sqrt{\\sum_{i=1}^{input dim} \\frac{(x_i-y_i)^2}{\\ell_i^2} }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -204,7 +204,7 @@ class sde_Exponential(Exponential):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r \\bigg) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} }
|
k(r) = \\sigma^2 \\exp \\bigg(- \\frac{1}{2} r \\bigg) \\ \\ \\ \\ \\text{ where } r = \\sqrt{\\sum_{i=1}^{input dim} \\frac{(x_i-y_i)^2}{\\ell_i^2} }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -259,7 +259,7 @@ class sde_RatQuad(RatQuad):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \\bigg( 1 + \\frac{r^2}{2} \\bigg)^{- \alpha} \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} }
|
k(r) = \\sigma^2 \\bigg( 1 + \\frac{r^2}{2} \\bigg)^{- \\alpha} \\ \\ \\ \\ \\text{ where } r = \\sqrt{\\sum_{i=1}^{input dim} \\frac{(x_i-y_i)^2}{\\ell_i^2} }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,19 +24,19 @@ class StdPeriodic(Kern):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \theta_1 \exp \left[ - \frac{1}{2} \sum_{i=1}^{input\_dim}
|
k(x,y) = \\theta_1 \\exp \\left[ - \\frac{1}{2} \\sum_{i=1}^{input\\_dim}
|
||||||
\left( \frac{\sin(\frac{\pi}{T_i} (x_i - y_i) )}{l_i} \right)^2 \right] }
|
\\left( \\frac{\\sin(\\frac{\\pi}{T_i} (x_i - y_i) )}{l_i} \\right)^2 \\right] }
|
||||||
|
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param variance: the variance :math:`\theta_1` in the formula above
|
:param variance: the variance :math:`\\theta_1` in the formula above
|
||||||
:type variance: float
|
:type variance: float
|
||||||
:param period: the vector of periods :math:`\T_i`. If None then 1.0 is assumed.
|
:param period: the vector of periods :math:`\\T_i`. If None then 1.0 is assumed.
|
||||||
:type period: array or list of the appropriate size (or float if there is only one period parameter)
|
:type period: array or list of the appropriate size (or float if there is only one period parameter)
|
||||||
:param lengthscale: the vector of lengthscale :math:`\l_i`. If None then 1.0 is assumed.
|
:param lengthscale: the vector of lengthscale :math:`\\l_i`. If None then 1.0 is assumed.
|
||||||
:type lengthscale: array or list of the appropriate size (or float if there is only one lengthscale parameter)
|
:type lengthscale: array or list of the appropriate size (or float if there is only one lengthscale parameter)
|
||||||
:param ARD1: Auto Relevance Determination with respect to period.
|
:param ARD1: Auto Relevance Determination with respect to period.
|
||||||
If equal to "False" one single period parameter :math:`\T_i` for
|
If equal to "False" one single period parameter :math:`\\T_i` for
|
||||||
each dimension is assumed, otherwise there is one lengthscale
|
each dimension is assumed, otherwise there is one lengthscale
|
||||||
parameter per dimension.
|
parameter per dimension.
|
||||||
:type ARD1: Boolean
|
:type ARD1: Boolean
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class Stationary(Kern):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
r(x, x') = \\sqrt{ \\sum_{q=1}^Q \\frac{(x_q - x'_q)^2}{\ell_q^2} }.
|
r(x, x') = \\sqrt{ \\sum_{q=1}^Q \\frac{(x_q - x'_q)^2}{\\ell_q^2} }.
|
||||||
|
|
||||||
By default, there's only one lengthscale: seaprate lengthscales for each
|
By default, there's only one lengthscale: seaprate lengthscales for each
|
||||||
dimension can be enables by setting ARD=True.
|
dimension can be enables by setting ARD=True.
|
||||||
|
|
@ -153,7 +153,7 @@ class Stationary(Kern):
|
||||||
Efficiently compute the scaled distance, r.
|
Efficiently compute the scaled distance, r.
|
||||||
|
|
||||||
..math::
|
..math::
|
||||||
r = \sqrt( \sum_{q=1}^Q (x_q - x'q)^2/l_q^2 )
|
r = \\sqrt( \\sum_{q=1}^Q (x_q - x'q)^2/l_q^2 )
|
||||||
|
|
||||||
Note that if thre is only one lengthscale, l comes outside the sum. In
|
Note that if thre is only one lengthscale, l comes outside the sum. In
|
||||||
this case we compute the unscaled distance first (in a separate
|
this case we compute the unscaled distance first (in a separate
|
||||||
|
|
@ -259,7 +259,7 @@ class Stationary(Kern):
|
||||||
the returned array is of shape [NxNxQxQ].
|
the returned array is of shape [NxNxQxQ].
|
||||||
|
|
||||||
..math:
|
..math:
|
||||||
\frac{\partial^2 K}{\partial X2 ^2} = - \frac{\partial^2 K}{\partial X\partial X2}
|
\\frac{\\partial^2 K}{\\partial X2 ^2} = - \\frac{\\partial^2 K}{\\partial X\\partial X2}
|
||||||
|
|
||||||
..returns:
|
..returns:
|
||||||
dL2_dXdX2: [NxMxQxQ] in the cov=True case, or [NxMxQ] in the cov=False case,
|
dL2_dXdX2: [NxMxQxQ] in the cov=True case, or [NxMxQ] in the cov=False case,
|
||||||
|
|
@ -295,7 +295,7 @@ class Stationary(Kern):
|
||||||
Given the derivative of the objective dL_dK, compute the second derivative of K wrt X:
|
Given the derivative of the objective dL_dK, compute the second derivative of K wrt X:
|
||||||
|
|
||||||
..math:
|
..math:
|
||||||
\frac{\partial^2 K}{\partial X\partial X}
|
\\frac{\\partial^2 K}{\\partial X\\partial X}
|
||||||
|
|
||||||
..returns:
|
..returns:
|
||||||
dL2_dXdX: [NxQxQ]
|
dL2_dXdX: [NxQxQ]
|
||||||
|
|
@ -423,7 +423,7 @@ class OU(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \\sigma^2 \exp(- r) \\ \\ \\ \\ \\text{ where } r = \sqrt{\sum_{i=1}^{\text{input_dim}} \\frac{(x_i-y_i)^2}{\ell_i^2} }
|
k(r) = \\sigma^2 \\exp(- r) \\ \\ \\ \\ \\text{ where } r = \\sqrt{\\sum_{i=1}^{\\text{input_dim}} \\frac{(x_i-y_i)^2}{\\ell_i^2} }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -460,7 +460,7 @@ class Matern32(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \\sigma^2 (1 + \\sqrt{3} r) \exp(- \sqrt{3} r) \\ \\ \\ \\ \\text{ where } r = \sqrt{\sum_{i=1}^{\\text{input_dim}} \\frac{(x_i-y_i)^2}{\ell_i^2} }
|
k(r) = \\sigma^2 (1 + \\sqrt{3} r) \\exp(- \\sqrt{3} r) \\ \\ \\ \\ \\text{ where } r = \\sqrt{\\sum_{i=1}^{\\text{input_dim}} \\frac{(x_i-y_i)^2}{\\ell_i^2} }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -559,7 +559,7 @@ class Matern52(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 (1 + \sqrt{5} r + \\frac53 r^2) \exp(- \sqrt{5} r)
|
k(r) = \\sigma^2 (1 + \\sqrt{5} r + \\frac53 r^2) \\exp(- \\sqrt{5} r)
|
||||||
"""
|
"""
|
||||||
def __init__(self, input_dim, variance=1., lengthscale=None, ARD=False, active_dims=None, name='Mat52'):
|
def __init__(self, input_dim, variance=1., lengthscale=None, ARD=False, active_dims=None, name='Mat52'):
|
||||||
super(Matern52, self).__init__(input_dim, variance, lengthscale, ARD, active_dims, name)
|
super(Matern52, self).__init__(input_dim, variance, lengthscale, ARD, active_dims, name)
|
||||||
|
|
@ -626,7 +626,7 @@ class ExpQuad(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \exp(- 0.5 r^2)
|
k(r) = \\sigma^2 \\exp(- 0.5 r^2)
|
||||||
|
|
||||||
notes::
|
notes::
|
||||||
- This is exactly the same as the RBF covariance function, but the
|
- This is exactly the same as the RBF covariance function, but the
|
||||||
|
|
@ -667,7 +667,7 @@ class Cosine(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \cos(r)
|
k(r) = \\sigma^2 \\cos(r)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, input_dim, variance=1., lengthscale=None, ARD=False, active_dims=None, name='Cosine'):
|
def __init__(self, input_dim, variance=1., lengthscale=None, ARD=False, active_dims=None, name='Cosine'):
|
||||||
|
|
@ -685,7 +685,7 @@ class ExpQuadCosine(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \exp(-2\pi^2r^2)\cos(2\pi r/T)
|
k(r) = \\sigma^2 \\exp(-2\\pi^2r^2)\\cos(2\\pi r/T)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -720,7 +720,7 @@ class Sinc(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \sinc(\pi r)
|
k(r) = \\sigma^2 \\sinc(\\pi r)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -742,7 +742,7 @@ class RatQuad(Stationary):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \\bigg( 1 + \\frac{r^2}{2} \\bigg)^{- \\alpha}
|
k(r) = \\sigma^2 \\bigg( 1 + \\frac{r^2}{2} \\bigg)^{- \\alpha}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class Eq_ode1(Kernpart):
|
||||||
|
|
||||||
This outputs of this kernel have the form
|
This outputs of this kernel have the form
|
||||||
.. math::
|
.. math::
|
||||||
\frac{\text{d}y_j}{\text{d}t} = \sum_{i=1}^R w_{j,i} f_i(t-\delta_j) +\sqrt{\kappa_j}g_j(t) - d_jy_j(t)
|
\\frac{\\text{d}y_j}{\\text{d}t} = \\sum_{i=1}^R w_{j,i} f_i(t-\\delta_j) +\\sqrt{\\kappa_j}g_j(t) - d_jy_j(t)
|
||||||
|
|
||||||
where :math:`R` is the rank of the system, :math:`w_{j,i}` is the sensitivity of the :math:`j`th output to the :math:`i`th latent function, :math:`d_j` is the decay rate of the :math:`j`th output and :math:`f_i(t)` and :math:`g_i(t)` are independent latent Gaussian processes goverened by an exponentiated quadratic covariance.
|
where :math:`R` is the rank of the system, :math:`w_{j,i}` is the sensitivity of the :math:`j`th output to the :math:`i`th latent function, :math:`d_j` is the decay rate of the :math:`j`th output and :math:`f_i(t)` and :math:`g_i(t)` are independent latent Gaussian processes goverened by an exponentiated quadratic covariance.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class Gibbs(Kernpart):
|
||||||
|
|
||||||
r = sqrt((x_i - x_j)'*(x_i - x_j))
|
r = sqrt((x_i - x_j)'*(x_i - x_j))
|
||||||
|
|
||||||
k(x_i, x_j) = \sigma^2*Z*exp(-r^2/(l(x)*l(x) + l(x')*l(x')))
|
k(x_i, x_j) = \\sigma^2*Z*exp(-r^2/(l(x)*l(x) + l(x')*l(x')))
|
||||||
|
|
||||||
Z = (2*l(x)*l(x')/(l(x)*l(x) + l(x')*l(x')^{q/2}
|
Z = (2*l(x)*l(x')/(l(x)*l(x) + l(x')*l(x')^{q/2}
|
||||||
|
|
||||||
|
|
@ -25,18 +25,18 @@ class Gibbs(Kernpart):
|
||||||
with input location. This leads to an additional term in front of
|
with input location. This leads to an additional term in front of
|
||||||
the kernel.
|
the kernel.
|
||||||
|
|
||||||
The parameters are :math:`\sigma^2`, the process variance, and
|
The parameters are :math:`\\sigma^2`, the process variance, and
|
||||||
the parameters of l(x) which is a function that can be
|
the parameters of l(x) which is a function that can be
|
||||||
specified by the user, by default an multi-layer peceptron is
|
specified by the user, by default an multi-layer peceptron is
|
||||||
used.
|
used.
|
||||||
|
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param variance: the variance :math:`\sigma^2`
|
:param variance: the variance :math:`\\sigma^2`
|
||||||
:type variance: float
|
:type variance: float
|
||||||
:param mapping: the mapping that gives the lengthscale across the input space (by default GPy.mappings.MLP is used with 20 hidden nodes).
|
:param mapping: the mapping that gives the lengthscale across the input space (by default GPy.mappings.MLP is used with 20 hidden nodes).
|
||||||
:type mapping: GPy.core.Mapping
|
:type mapping: GPy.core.Mapping
|
||||||
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one weight variance parameter \sigma^2_w), otherwise there is one weight variance parameter per dimension.
|
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one weight variance parameter \\sigma^2_w), otherwise there is one weight variance parameter per dimension.
|
||||||
:type ARD: Boolean
|
:type ARD: Boolean
|
||||||
:rtype: Kernpart object
|
:rtype: Kernpart object
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@ class Hetero(Kernpart):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x_i, x_j) = \delta_{i,j} \sigma^2(x_i)
|
k(x_i, x_j) = \\delta_{i,j} \\sigma^2(x_i)
|
||||||
|
|
||||||
where :math:`\sigma^2(x)` is a function giving the variance as a function of input space and :math:`\delta_{i,j}` is the Kronecker delta function.
|
where :math:`\\sigma^2(x)` is a function giving the variance as a function of input space and :math:`\\delta_{i,j}` is the Kronecker delta function.
|
||||||
|
|
||||||
The parameters are the parameters of \sigma^2(x) which is a
|
The parameters are the parameters of \\sigma^2(x) which is a
|
||||||
function that can be specified by the user, by default an
|
function that can be specified by the user, by default an
|
||||||
multi-layer peceptron is used.
|
multi-layer peceptron is used.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,28 +11,28 @@ class POLY(Kernpart):
|
||||||
Polynomial kernel parameter initialisation. Included for completeness, but generally not recommended, is the polynomial kernel:
|
Polynomial kernel parameter initialisation. Included for completeness, but generally not recommended, is the polynomial kernel:
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
k(x, y) = \sigma^2\*(\sigma_w^2 x'y+\sigma_b^b)^d
|
k(x, y) = \\sigma^2\\*(\\sigma_w^2 x'y+\\sigma_b^b)^d
|
||||||
|
|
||||||
The kernel parameters are :math:`\sigma^2` (variance), :math:`\sigma^2_w`
|
The kernel parameters are :math:`\\sigma^2` (variance), :math:`\\sigma^2_w`
|
||||||
(weight_variance), :math:`\sigma^2_b` (bias_variance) and d
|
(weight_variance), :math:`\\sigma^2_b` (bias_variance) and d
|
||||||
(degree). Only gradients of the first three are provided for
|
(degree). Only gradients of the first three are provided for
|
||||||
kernel optimisation, it is assumed that polynomial degree would
|
kernel optimisation, it is assumed that polynomial degree would
|
||||||
be set by hand.
|
be set by hand.
|
||||||
|
|
||||||
The kernel is not recommended as it is badly behaved when the
|
The kernel is not recommended as it is badly behaved when the
|
||||||
:math:`\sigma^2_w\*x'\*y + \sigma^2_b` has a magnitude greater than one. For completeness
|
:math:`\\sigma^2_w\\*x'\\*y + \\sigma^2_b` has a magnitude greater than one. For completeness
|
||||||
there is an automatic relevance determination version of this
|
there is an automatic relevance determination version of this
|
||||||
kernel provided (NOTE YET IMPLEMENTED!).
|
kernel provided (NOTE YET IMPLEMENTED!).
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param variance: the variance :math:`\sigma^2`
|
:param variance: the variance :math:`\\sigma^2`
|
||||||
:type variance: float
|
:type variance: float
|
||||||
:param weight_variance: the vector of the variances of the prior over input weights in the neural network :math:`\sigma^2_w`
|
:param weight_variance: the vector of the variances of the prior over input weights in the neural network :math:`\\sigma^2_w`
|
||||||
:type weight_variance: array or list of the appropriate size (or float if there is only one weight variance parameter)
|
:type weight_variance: array or list of the appropriate size (or float if there is only one weight variance parameter)
|
||||||
:param bias_variance: the variance of the prior over bias parameters :math:`\sigma^2_b`
|
:param bias_variance: the variance of the prior over bias parameters :math:`\\sigma^2_b`
|
||||||
:param degree: the degree of the polynomial.
|
:param degree: the degree of the polynomial.
|
||||||
:type degree: int
|
:type degree: int
|
||||||
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one weight variance parameter :math:`\sigma^2_w`), otherwise there is one weight variance parameter per dimension.
|
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one weight variance parameter :math:`\\sigma^2_w`), otherwise there is one weight variance parameter per dimension.
|
||||||
:type ARD: Boolean
|
:type ARD: Boolean
|
||||||
:rtype: Kernpart object
|
:rtype: Kernpart object
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ class RBFInv(RBF):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r^2 \\bigg) \ \ \ \ \ \\text{ where } r^2 = \sum_{i=1}^d \\frac{ (x_i-x^\prime_i)^2}{\ell_i^2}
|
k(r) = \\sigma^2 \\exp \\bigg(- \\frac{1}{2} r^2 \\bigg) \\ \\ \\ \\ \\ \\text{ where } r^2 = \\sum_{i=1}^d \\frac{ (x_i-x^\\prime_i)^2}{\\ell_i^2}
|
||||||
|
|
||||||
where \ell_i is the lengthscale, \sigma^2 the variance and d the dimensionality of the input.
|
where \\ell_i is the lengthscale, \\sigma^2 the variance and d the dimensionality of the input.
|
||||||
|
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
|
|
@ -25,7 +25,7 @@ class RBFInv(RBF):
|
||||||
:type variance: float
|
:type variance: float
|
||||||
:param lengthscale: the vector of lengthscale of the kernel
|
:param lengthscale: the vector of lengthscale of the kernel
|
||||||
:type lengthscale: array or list of the appropriate size (or float if there is only one lengthscale parameter)
|
:type lengthscale: array or list of the appropriate size (or float if there is only one lengthscale parameter)
|
||||||
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one single lengthscale parameter \ell), otherwise there is one lengthscale parameter per dimension.
|
:param ARD: Auto Relevance Determination. If equal to "False", the kernel is isotropic (ie. one single lengthscale parameter \\ell), otherwise there is one lengthscale parameter per dimension.
|
||||||
:type ARD: Boolean
|
:type ARD: Boolean
|
||||||
:rtype: kernel object
|
:rtype: kernel object
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,15 @@ class TruncLinear(Kern):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \sum_{i=1}^input_dim \sigma^2_i \max(0, x_iy_i - \sigma_q)
|
k(x,y) = \\sum_{i=1}^input_dim \\sigma^2_i \\max(0, x_iy_i - \\sigma_q)
|
||||||
|
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param variances: the vector of variances :math:`\sigma^2_i`
|
:param variances: the vector of variances :math:`\\sigma^2_i`
|
||||||
:type variances: array or list of the appropriate size (or float if there
|
:type variances: array or list of the appropriate size (or float if there
|
||||||
is only one variance parameter)
|
is only one variance parameter)
|
||||||
:param ARD: Auto Relevance Determination. If False, the kernel has only one
|
:param ARD: Auto Relevance Determination. If False, the kernel has only one
|
||||||
variance parameter \sigma^2, otherwise there is one variance
|
variance parameter \\sigma^2, otherwise there is one variance
|
||||||
parameter per dimension.
|
parameter per dimension.
|
||||||
:type ARD: Boolean
|
:type ARD: Boolean
|
||||||
:rtype: kernel object
|
:rtype: kernel object
|
||||||
|
|
@ -113,15 +113,15 @@ class TruncLinear_inf(Kern):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
k(x,y) = \sum_{i=1}^input_dim \sigma^2_i \max(0, x_iy_i - \sigma_q)
|
k(x,y) = \\sum_{i=1}^input_dim \\sigma^2_i \\max(0, x_iy_i - \\sigma_q)
|
||||||
|
|
||||||
:param input_dim: the number of input dimensions
|
:param input_dim: the number of input dimensions
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param variances: the vector of variances :math:`\sigma^2_i`
|
:param variances: the vector of variances :math:`\\sigma^2_i`
|
||||||
:type variances: array or list of the appropriate size (or float if there
|
:type variances: array or list of the appropriate size (or float if there
|
||||||
is only one variance parameter)
|
is only one variance parameter)
|
||||||
:param ARD: Auto Relevance Determination. If False, the kernel has only one
|
:param ARD: Auto Relevance Determination. If False, the kernel has only one
|
||||||
variance parameter \sigma^2, otherwise there is one variance
|
variance parameter \\sigma^2, otherwise there is one variance
|
||||||
parameter per dimension.
|
parameter per dimension.
|
||||||
:type ARD: Boolean
|
:type ARD: Boolean
|
||||||
:rtype: kernel object
|
:rtype: kernel object
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ class Bernoulli(Likelihood):
|
||||||
assert np.atleast_1d(inv_link_f).shape == np.atleast_1d(y).shape
|
assert np.atleast_1d(inv_link_f).shape == np.atleast_1d(y).shape
|
||||||
#d3logpdf_dlink3 = 2*(y/(inv_link_f**3) - (1-y)/((1-inv_link_f)**3))
|
#d3logpdf_dlink3 = 2*(y/(inv_link_f**3) - (1-y)/((1-inv_link_f)**3))
|
||||||
state = np.seterr(divide='ignore')
|
state = np.seterr(divide='ignore')
|
||||||
# TODO check y \in {0, 1} or {-1, 1}
|
# TODO check y \\in {0, 1} or {-1, 1}
|
||||||
d3logpdf_dlink3 = np.where(y==1, 2./(inv_link_f**3), -2./((1.-inv_link_f)**3))
|
d3logpdf_dlink3 = np.where(y==1, 2./(inv_link_f**3), -2./((1.-inv_link_f)**3))
|
||||||
np.seterr(**state)
|
np.seterr(**state)
|
||||||
return d3logpdf_dlink3
|
return d3logpdf_dlink3
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class Exponential(Likelihood):
|
||||||
Y is expected to take values in {0,1,2,...}
|
Y is expected to take values in {0,1,2,...}
|
||||||
-----
|
-----
|
||||||
$$
|
$$
|
||||||
L(x) = \exp(\lambda) * \lambda**Y_i / Y_i!
|
L(x) = \\exp(\\lambda) * \\lambda**Y_i / Y_i!
|
||||||
$$
|
$$
|
||||||
"""
|
"""
|
||||||
def __init__(self,gp_link=None):
|
def __init__(self,gp_link=None):
|
||||||
|
|
@ -46,7 +46,7 @@ class Exponential(Likelihood):
|
||||||
Log Likelihood Function given link(f)
|
Log Likelihood Function given link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\ln p(y_{i}|\lambda(f_{i})) = \\ln \\lambda(f_{i}) - y_{i}\\lambda(f_{i})
|
\\ln p(y_{i}|\\lambda(f_{i})) = \\ln \\lambda(f_{i}) - y_{i}\\lambda(f_{i})
|
||||||
|
|
||||||
:param link_f: latent variables (link(f))
|
:param link_f: latent variables (link(f))
|
||||||
:type link_f: Nx1 array
|
:type link_f: Nx1 array
|
||||||
|
|
@ -65,7 +65,7 @@ class Exponential(Likelihood):
|
||||||
Gradient of the log likelihood function at y, given link(f) w.r.t link(f)
|
Gradient of the log likelihood function at y, given link(f) w.r.t link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d \\ln p(y_{i}|\lambda(f_{i}))}{d\\lambda(f)} = \\frac{1}{\\lambda(f)} - y_{i}
|
\\frac{d \\ln p(y_{i}|\\lambda(f_{i}))}{d\\lambda(f)} = \\frac{1}{\\lambda(f)} - y_{i}
|
||||||
|
|
||||||
:param link_f: latent variables (f)
|
:param link_f: latent variables (f)
|
||||||
:type link_f: Nx1 array
|
:type link_f: Nx1 array
|
||||||
|
|
@ -87,7 +87,7 @@ class Exponential(Likelihood):
|
||||||
The hessian will be 0 unless i == j
|
The hessian will be 0 unless i == j
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{2} \\ln p(y_{i}|\lambda(f_{i}))}{d^{2}\\lambda(f)} = -\\frac{1}{\\lambda(f_{i})^{2}}
|
\\frac{d^{2} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{2}\\lambda(f)} = -\\frac{1}{\\lambda(f_{i})^{2}}
|
||||||
|
|
||||||
:param link_f: latent variables link(f)
|
:param link_f: latent variables link(f)
|
||||||
:type link_f: Nx1 array
|
:type link_f: Nx1 array
|
||||||
|
|
@ -110,7 +110,7 @@ class Exponential(Likelihood):
|
||||||
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{3} \\ln p(y_{i}|\lambda(f_{i}))}{d^{3}\\lambda(f)} = \\frac{2}{\\lambda(f_{i})^{3}}
|
\\frac{d^{3} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{3}\\lambda(f)} = \\frac{2}{\\lambda(f_{i})^{3}}
|
||||||
|
|
||||||
:param link_f: latent variables link(f)
|
:param link_f: latent variables link(f)
|
||||||
:type link_f: Nx1 array
|
:type link_f: Nx1 array
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Gamma(Likelihood):
|
||||||
Log Likelihood Function given link(f)
|
Log Likelihood Function given link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\ln p(y_{i}|\lambda(f_{i})) = \\alpha_{i}\\log \\beta - \\log \\Gamma(\\alpha_{i}) + (\\alpha_{i} - 1)\\log y_{i} - \\beta y_{i}\\\\
|
\\ln p(y_{i}|\\lambda(f_{i})) = \\alpha_{i}\\log \\beta - \\log \\Gamma(\\alpha_{i}) + (\\alpha_{i} - 1)\\log y_{i} - \\beta y_{i}\\\\
|
||||||
\\alpha_{i} = \\beta y_{i}
|
\\alpha_{i} = \\beta y_{i}
|
||||||
|
|
||||||
:param link_f: latent variables (link(f))
|
:param link_f: latent variables (link(f))
|
||||||
|
|
@ -101,7 +101,7 @@ class Gamma(Likelihood):
|
||||||
The hessian will be 0 unless i == j
|
The hessian will be 0 unless i == j
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{2} \\ln p(y_{i}|\lambda(f_{i}))}{d^{2}\\lambda(f)} = -\\beta^{2}\\frac{d\\Psi(\\alpha_{i})}{d\\alpha_{i}}\\\\
|
\\frac{d^{2} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{2}\\lambda(f)} = -\\beta^{2}\\frac{d\\Psi(\\alpha_{i})}{d\\alpha_{i}}\\\\
|
||||||
\\alpha_{i} = \\beta y_{i}
|
\\alpha_{i} = \\beta y_{i}
|
||||||
|
|
||||||
:param link_f: latent variables link(f)
|
:param link_f: latent variables link(f)
|
||||||
|
|
@ -126,7 +126,7 @@ class Gamma(Likelihood):
|
||||||
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{3} \\ln p(y_{i}|\lambda(f_{i}))}{d^{3}\\lambda(f)} = -\\beta^{3}\\frac{d^{2}\\Psi(\\alpha_{i})}{d\\alpha_{i}}\\\\
|
\\frac{d^{3} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{3}\\lambda(f)} = -\\beta^{3}\\frac{d^{2}\\Psi(\\alpha_{i})}{d\\alpha_{i}}\\\\
|
||||||
\\alpha_{i} = \\beta y_{i}
|
\\alpha_{i} = \\beta y_{i}
|
||||||
|
|
||||||
:param link_f: latent variables link(f)
|
:param link_f: latent variables link(f)
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ class Likelihood(Parameterized):
|
||||||
Calculation of the log predictive density
|
Calculation of the log predictive density
|
||||||
|
|
||||||
.. math:
|
.. math:
|
||||||
p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\mu_{*}\\sigma^{2}_{*})
|
p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\\mu_{*}\\sigma^{2}_{*})
|
||||||
|
|
||||||
:param y_test: test observations (y_{*})
|
:param y_test: test observations (y_{*})
|
||||||
:type y_test: (Nx1) array
|
:type y_test: (Nx1) array
|
||||||
|
|
@ -199,7 +199,7 @@ class Likelihood(Parameterized):
|
||||||
|
|
||||||
.. math:
|
.. math:
|
||||||
log p(y_{*}|D) = log 1/num_samples prod^{S}_{s=1} p(y_{*}|f_{*s})
|
log p(y_{*}|D) = log 1/num_samples prod^{S}_{s=1} p(y_{*}|f_{*s})
|
||||||
f_{*s} ~ p(f_{*}|\mu_{*}\\sigma^{2}_{*})
|
f_{*s} ~ p(f_{*}|\\mu_{*}\\sigma^{2}_{*})
|
||||||
|
|
||||||
:param y_test: test observations (y_{*})
|
:param y_test: test observations (y_{*})
|
||||||
:type y_test: (Nx1) array
|
:type y_test: (Nx1) array
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ class Cloglog(GPTransformation):
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
f = \log (-\log(1-p))
|
f = \\log (-\\log(1-p))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def transf(self,f):
|
def transf(self,f):
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Poisson(Likelihood):
|
||||||
Log Likelihood Function given link(f)
|
Log Likelihood Function given link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\ln p(y_{i}|\lambda(f_{i})) = -\\lambda(f_{i}) + y_{i}\\log \\lambda(f_{i}) - \\log y_{i}!
|
\\ln p(y_{i}|\\lambda(f_{i})) = -\\lambda(f_{i}) + y_{i}\\log \\lambda(f_{i}) - \\log y_{i}!
|
||||||
|
|
||||||
:param link_f: latent variables (link(f))
|
:param link_f: latent variables (link(f))
|
||||||
:type link_f: Nx1 array
|
:type link_f: Nx1 array
|
||||||
|
|
@ -72,7 +72,7 @@ class Poisson(Likelihood):
|
||||||
Gradient of the log likelihood function at y, given link(f) w.r.t link(f)
|
Gradient of the log likelihood function at y, given link(f) w.r.t link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d \\ln p(y_{i}|\lambda(f_{i}))}{d\\lambda(f)} = \\frac{y_{i}}{\\lambda(f_{i})} - 1
|
\\frac{d \\ln p(y_{i}|\\lambda(f_{i}))}{d\\lambda(f)} = \\frac{y_{i}}{\\lambda(f_{i})} - 1
|
||||||
|
|
||||||
:param link_f: latent variables (f)
|
:param link_f: latent variables (f)
|
||||||
:type link_f: Nx1 array
|
:type link_f: Nx1 array
|
||||||
|
|
@ -92,7 +92,7 @@ class Poisson(Likelihood):
|
||||||
The hessian will be 0 unless i == j
|
The hessian will be 0 unless i == j
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{2} \\ln p(y_{i}|\lambda(f_{i}))}{d^{2}\\lambda(f)} = \\frac{-y_{i}}{\\lambda(f_{i})^{2}}
|
\\frac{d^{2} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{2}\\lambda(f)} = \\frac{-y_{i}}{\\lambda(f_{i})^{2}}
|
||||||
|
|
||||||
:param link_f: latent variables link(f)
|
:param link_f: latent variables link(f)
|
||||||
:type link_f: Nx1 array
|
:type link_f: Nx1 array
|
||||||
|
|
@ -113,7 +113,7 @@ class Poisson(Likelihood):
|
||||||
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{3} \\ln p(y_{i}|\lambda(f_{i}))}{d^{3}\\lambda(f)} = \\frac{2y_{i}}{\\lambda(f_{i})^{3}}
|
\\frac{d^{3} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{3}\\lambda(f)} = \\frac{2y_{i}}{\\lambda(f_{i})^{3}}
|
||||||
|
|
||||||
:param link_f: latent variables link(f)
|
:param link_f: latent variables link(f)
|
||||||
:type link_f: Nx1 array
|
:type link_f: Nx1 array
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class StudentT(Likelihood):
|
||||||
Log Likelihood Function given link(f)
|
Log Likelihood Function given link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\ln p(y_{i}|\lambda(f_{i})) = \\ln \\Gamma\\left(\\frac{v+1}{2}\\right) - \\ln \\Gamma\\left(\\frac{v}{2}\\right) - \\ln \\sqrt{v \\pi\\sigma^{2}} - \\frac{v+1}{2}\\ln \\left(1 + \\frac{1}{v}\\left(\\frac{(y_{i} - \lambda(f_{i}))^{2}}{\\sigma^{2}}\\right)\\right)
|
\\ln p(y_{i}|\\lambda(f_{i})) = \\ln \\Gamma\\left(\\frac{v+1}{2}\\right) - \\ln \\Gamma\\left(\\frac{v}{2}\\right) - \\ln \\sqrt{v \\pi\\sigma^{2}} - \\frac{v+1}{2}\\ln \\left(1 + \\frac{1}{v}\\left(\\frac{(y_{i} - \\lambda(f_{i}))^{2}}{\\sigma^{2}}\\right)\\right)
|
||||||
|
|
||||||
:param inv_link_f: latent variables (link(f))
|
:param inv_link_f: latent variables (link(f))
|
||||||
:type inv_link_f: Nx1 array
|
:type inv_link_f: Nx1 array
|
||||||
|
|
@ -107,7 +107,7 @@ class StudentT(Likelihood):
|
||||||
Gradient of the log likelihood function at y, given link(f) w.r.t link(f)
|
Gradient of the log likelihood function at y, given link(f) w.r.t link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d \\ln p(y_{i}|\lambda(f_{i}))}{d\\lambda(f)} = \\frac{(v+1)(y_{i}-\lambda(f_{i}))}{(y_{i}-\lambda(f_{i}))^{2} + \\sigma^{2}v}
|
\\frac{d \\ln p(y_{i}|\\lambda(f_{i}))}{d\\lambda(f)} = \\frac{(v+1)(y_{i}-\\lambda(f_{i}))}{(y_{i}-\\lambda(f_{i}))^{2} + \\sigma^{2}v}
|
||||||
|
|
||||||
:param inv_link_f: latent variables (f)
|
:param inv_link_f: latent variables (f)
|
||||||
:type inv_link_f: Nx1 array
|
:type inv_link_f: Nx1 array
|
||||||
|
|
@ -129,7 +129,7 @@ class StudentT(Likelihood):
|
||||||
The hessian will be 0 unless i == j
|
The hessian will be 0 unless i == j
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{2} \\ln p(y_{i}|\lambda(f_{i}))}{d^{2}\\lambda(f)} = \\frac{(v+1)((y_{i}-\lambda(f_{i}))^{2} - \\sigma^{2}v)}{((y_{i}-\lambda(f_{i}))^{2} + \\sigma^{2}v)^{2}}
|
\\frac{d^{2} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{2}\\lambda(f)} = \\frac{(v+1)((y_{i}-\\lambda(f_{i}))^{2} - \\sigma^{2}v)}{((y_{i}-\\lambda(f_{i}))^{2} + \\sigma^{2}v)^{2}}
|
||||||
|
|
||||||
:param inv_link_f: latent variables inv_link(f)
|
:param inv_link_f: latent variables inv_link(f)
|
||||||
:type inv_link_f: Nx1 array
|
:type inv_link_f: Nx1 array
|
||||||
|
|
@ -154,7 +154,7 @@ class StudentT(Likelihood):
|
||||||
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{3} \\ln p(y_{i}|\lambda(f_{i}))}{d^{3}\\lambda(f)} = \\frac{-2(v+1)((y_{i} - \lambda(f_{i}))^3 - 3(y_{i} - \lambda(f_{i})) \\sigma^{2} v))}{((y_{i} - \lambda(f_{i})) + \\sigma^{2} v)^3}
|
\\frac{d^{3} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{3}\\lambda(f)} = \\frac{-2(v+1)((y_{i} - \\lambda(f_{i}))^3 - 3(y_{i} - \\lambda(f_{i})) \\sigma^{2} v))}{((y_{i} - \\lambda(f_{i})) + \\sigma^{2} v)^3}
|
||||||
|
|
||||||
:param inv_link_f: latent variables link(f)
|
:param inv_link_f: latent variables link(f)
|
||||||
:type inv_link_f: Nx1 array
|
:type inv_link_f: Nx1 array
|
||||||
|
|
@ -175,7 +175,7 @@ class StudentT(Likelihood):
|
||||||
Gradient of the log-likelihood function at y given f, w.r.t variance parameter (t_noise)
|
Gradient of the log-likelihood function at y given f, w.r.t variance parameter (t_noise)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d \\ln p(y_{i}|\lambda(f_{i}))}{d\\sigma^{2}} = \\frac{v((y_{i} - \lambda(f_{i}))^{2} - \\sigma^{2})}{2\\sigma^{2}(\\sigma^{2}v + (y_{i} - \lambda(f_{i}))^{2})}
|
\\frac{d \\ln p(y_{i}|\\lambda(f_{i}))}{d\\sigma^{2}} = \\frac{v((y_{i} - \\lambda(f_{i}))^{2} - \\sigma^{2})}{2\\sigma^{2}(\\sigma^{2}v + (y_{i} - \\lambda(f_{i}))^{2})}
|
||||||
|
|
||||||
:param inv_link_f: latent variables link(f)
|
:param inv_link_f: latent variables link(f)
|
||||||
:type inv_link_f: Nx1 array
|
:type inv_link_f: Nx1 array
|
||||||
|
|
@ -199,7 +199,7 @@ class StudentT(Likelihood):
|
||||||
Derivative of the dlogpdf_dlink w.r.t variance parameter (t_noise)
|
Derivative of the dlogpdf_dlink w.r.t variance parameter (t_noise)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d}{d\\sigma^{2}}(\\frac{d \\ln p(y_{i}|\lambda(f_{i}))}{df}) = \\frac{-2\\sigma v(v + 1)(y_{i}-\lambda(f_{i}))}{(y_{i}-\lambda(f_{i}))^2 + \\sigma^2 v)^2}
|
\\frac{d}{d\\sigma^{2}}(\\frac{d \\ln p(y_{i}|\\lambda(f_{i}))}{df}) = \\frac{-2\\sigma v(v + 1)(y_{i}-\\lambda(f_{i}))}{(y_{i}-\\lambda(f_{i}))^2 + \\sigma^2 v)^2}
|
||||||
|
|
||||||
:param inv_link_f: latent variables inv_link_f
|
:param inv_link_f: latent variables inv_link_f
|
||||||
:type inv_link_f: Nx1 array
|
:type inv_link_f: Nx1 array
|
||||||
|
|
@ -220,7 +220,7 @@ class StudentT(Likelihood):
|
||||||
Gradient of the hessian (d2logpdf_dlink2) w.r.t variance parameter (t_noise)
|
Gradient of the hessian (d2logpdf_dlink2) w.r.t variance parameter (t_noise)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d}{d\\sigma^{2}}(\\frac{d^{2} \\ln p(y_{i}|\lambda(f_{i}))}{d^{2}f}) = \\frac{v(v+1)(\\sigma^{2}v - 3(y_{i} - \lambda(f_{i}))^{2})}{(\\sigma^{2}v + (y_{i} - \lambda(f_{i}))^{2})^{3}}
|
\\frac{d}{d\\sigma^{2}}(\\frac{d^{2} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{2}f}) = \\frac{v(v+1)(\\sigma^{2}v - 3(y_{i} - \\lambda(f_{i}))^{2})}{(\\sigma^{2}v + (y_{i} - \\lambda(f_{i}))^{2})^{3}}
|
||||||
|
|
||||||
:param inv_link_f: latent variables link(f)
|
:param inv_link_f: latent variables link(f)
|
||||||
:type inv_link_f: Nx1 array
|
:type inv_link_f: Nx1 array
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Weibull(Likelihood):
|
||||||
Log Likelihood Function given link(f)
|
Log Likelihood Function given link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\ln p(y_{i}|\lambda(f_{i})) = \\alpha_{i}\\log \\beta - \\log \\Gamma(\\alpha_{i}) + (\\alpha_{i} - 1)\\log y_{i} - \\beta y_{i}\\\\
|
\\ln p(y_{i}|\\lambda(f_{i})) = \\alpha_{i}\\log \\beta - \\log \\Gamma(\\alpha_{i}) + (\\alpha_{i} - 1)\\log y_{i} - \\beta y_{i}\\\\
|
||||||
\\alpha_{i} = \\beta y_{i}
|
\\alpha_{i} = \\beta y_{i}
|
||||||
|
|
||||||
:param link_f: latent variables (link(f))
|
:param link_f: latent variables (link(f))
|
||||||
|
|
@ -117,7 +117,7 @@ class Weibull(Likelihood):
|
||||||
The hessian will be 0 unless i == j
|
The hessian will be 0 unless i == j
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{2} \\ln p(y_{i}|\lambda(f_{i}))}{d^{2}\\lambda(f)} = -\\beta^{2}\\frac{d\\Psi(\\alpha_{i})}{d\\alpha_{i}}\\\\
|
\\frac{d^{2} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{2}\\lambda(f)} = -\\beta^{2}\\frac{d\\Psi(\\alpha_{i})}{d\\alpha_{i}}\\\\
|
||||||
\\alpha_{i} = \\beta y_{i}
|
\\alpha_{i} = \\beta y_{i}
|
||||||
|
|
||||||
:param link_f: latent variables link(f)
|
:param link_f: latent variables link(f)
|
||||||
|
|
@ -150,7 +150,7 @@ class Weibull(Likelihood):
|
||||||
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
Third order derivative log-likelihood function at y given link(f) w.r.t link(f)
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\\frac{d^{3} \\ln p(y_{i}|\lambda(f_{i}))}{d^{3}\\lambda(f)} = -\\beta^{3}\\frac{d^{2}\\Psi(\\alpha_{i})}{d\\alpha_{i}}\\\\
|
\\frac{d^{3} \\ln p(y_{i}|\\lambda(f_{i}))}{d^{3}\\lambda(f)} = -\\beta^{3}\\frac{d^{2}\\Psi(\\alpha_{i})}{d\\alpha_{i}}\\\\
|
||||||
\\alpha_{i} = \\beta y_{i}
|
\\alpha_{i} = \\beta y_{i}
|
||||||
|
|
||||||
:param link_f: latent variables link(f)
|
:param link_f: latent variables link(f)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class Additive(Mapping):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
f(\mathbf{x}*) = f_1(\mathbf{x}*) + f_2(\mathbf(x)*)
|
f(\\mathbf{x}*) = f_1(\\mathbf{x}*) + f_2(\\mathbf(x)*)
|
||||||
|
|
||||||
:param mapping1: first mapping to add together.
|
:param mapping1: first mapping to add together.
|
||||||
:type mapping1: GPy.mappings.Mapping
|
:type mapping1: GPy.mappings.Mapping
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class Compound(Mapping):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
f(\mathbf{x}) = f_2(f_1(\mathbf{x}))
|
f(\\mathbf{x}) = f_2(f_1(\\mathbf{x}))
|
||||||
|
|
||||||
:param mapping1: first mapping
|
:param mapping1: first mapping
|
||||||
:type mapping1: GPy.mappings.Mapping
|
:type mapping1: GPy.mappings.Mapping
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class Constant(Mapping):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
F(\mathbf{x}) = c
|
F(\\mathbf{x}) = c
|
||||||
|
|
||||||
|
|
||||||
:param input_dim: dimension of input.
|
:param input_dim: dimension of input.
|
||||||
|
|
|
||||||
|
|
@ -12,20 +12,20 @@ class Kernel(Mapping):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
f(\mathbf{x}) = \sum_i \alpha_i k(\mathbf{z}_i, \mathbf{x})
|
f(\\mathbf{x}) = \\sum_i \\alpha_i k(\\mathbf{z}_i, \\mathbf{x})
|
||||||
|
|
||||||
or for multple outputs
|
or for multple outputs
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
f_i(\mathbf{x}) = \sum_j \alpha_{i,j} k(\mathbf{z}_i, \mathbf{x})
|
f_i(\\mathbf{x}) = \\sum_j \\alpha_{i,j} k(\\mathbf{z}_i, \\mathbf{x})
|
||||||
|
|
||||||
|
|
||||||
:param input_dim: dimension of input.
|
:param input_dim: dimension of input.
|
||||||
:type input_dim: int
|
:type input_dim: int
|
||||||
:param output_dim: dimension of output.
|
:param output_dim: dimension of output.
|
||||||
:type output_dim: int
|
:type output_dim: int
|
||||||
:param Z: input observations containing :math:`\mathbf{Z}`
|
:param Z: input observations containing :math:`\\mathbf{Z}`
|
||||||
:type Z: ndarray
|
:type Z: ndarray
|
||||||
:param kernel: a GPy kernel, defaults to GPy.kern.RBF
|
:param kernel: a GPy kernel, defaults to GPy.kern.RBF
|
||||||
:type kernel: GPy.kern.kern
|
:type kernel: GPy.kern.kern
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class Linear(Mapping):
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
F(\mathbf{x}) = \mathbf{A} \mathbf{x})
|
F(\\mathbf{x}) = \\mathbf{A} \\mathbf{x})
|
||||||
|
|
||||||
|
|
||||||
:param input_dim: dimension of input.
|
:param input_dim: dimension of input.
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class GPKroneckerGaussianRegression(Model):
|
||||||
|
|
||||||
.. rubric:: References
|
.. rubric:: References
|
||||||
|
|
||||||
.. [stegle_et_al_2011] Stegle, O.; Lippert, C.; Mooij, J.M.; Lawrence, N.D.; Borgwardt, K.:Efficient inference in matrix-variate Gaussian models with \iid observation noise. In: Advances in Neural Information Processing Systems, 2011, Pages 630-638
|
.. [stegle_et_al_2011] Stegle, O.; Lippert, C.; Mooij, J.M.; Lawrence, N.D.; Borgwardt, K.:Efficient inference in matrix-variate Gaussian models with \\iid observation noise. In: Advances in Neural Information Processing Systems, 2011, Pages 630-638
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, X1, X2, Y, kern1, kern2, noise_var=1., name='KGPR'):
|
def __init__(self, X1, X2, Y, kern1, kern2, noise_var=1., name='KGPR'):
|
||||||
|
|
|
||||||
|
|
@ -4002,10 +4002,10 @@ class ContDescrStateSpace(DescreteStateSpace):
|
||||||
"""
|
"""
|
||||||
Linear Time-Invariant Stochastic Differential Equation (LTI SDE):
|
Linear Time-Invariant Stochastic Differential Equation (LTI SDE):
|
||||||
|
|
||||||
dx(t) = F x(t) dt + L d \beta ,where
|
dx(t) = F x(t) dt + L d \\beta ,where
|
||||||
|
|
||||||
x(t): (vector) stochastic process
|
x(t): (vector) stochastic process
|
||||||
\beta: (vector) Brownian motion process
|
\\beta: (vector) Brownian motion process
|
||||||
F, L: (time invariant) matrices of corresponding dimensions
|
F, L: (time invariant) matrices of corresponding dimensions
|
||||||
Qc: covariance of noise.
|
Qc: covariance of noise.
|
||||||
|
|
||||||
|
|
@ -4022,7 +4022,7 @@ class ContDescrStateSpace(DescreteStateSpace):
|
||||||
F,L: LTI SDE matrices of corresponding dimensions
|
F,L: LTI SDE matrices of corresponding dimensions
|
||||||
|
|
||||||
Qc: matrix (n,n)
|
Qc: matrix (n,n)
|
||||||
Covarince between different dimensions of noise \beta.
|
Covarince between different dimensions of noise \\beta.
|
||||||
n is the dimensionality of the noise.
|
n is the dimensionality of the noise.
|
||||||
|
|
||||||
dt: double or iterable
|
dt: double or iterable
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ class TPRegression(Model):
|
||||||
|
|
||||||
def log_likelihood(self):
|
def log_likelihood(self):
|
||||||
"""
|
"""
|
||||||
The log marginal likelihood of the model, :math:`p(\mathbf{y})`, this is the objective function of the model being optimised
|
The log marginal likelihood of the model, :math:`p(\\mathbf{y})`, this is the objective function of the model being optimised
|
||||||
"""
|
"""
|
||||||
return self._log_marginal_likelihood or self.inference()[1]
|
return self._log_marginal_likelihood or self.inference()[1]
|
||||||
|
|
||||||
|
|
@ -184,10 +184,10 @@ class TPRegression(Model):
|
||||||
diagonal of the covariance is returned.
|
diagonal of the covariance is returned.
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
p(f*|X*, X, Y) = \int^{\inf}_{\inf} p(f*|f,X*)p(f|X,Y) df
|
p(f*|X*, X, Y) = \\int^{\\inf}_{\\inf} p(f*|f,X*)p(f|X,Y) df
|
||||||
= MVN\left(\nu + N,f*| K_{x*x}(K_{xx})^{-1}Y,
|
= MVN\\left(\\nu + N,f*| K_{x*x}(K_{xx})^{-1}Y,
|
||||||
\frac{\nu + \beta - 2}{\nu + N - 2}K_{x*x*} - K_{xx*}(K_{xx})^{-1}K_{xx*}\right)
|
\\frac{\\nu + \\beta - 2}{\\nu + N - 2}K_{x*x*} - K_{xx*}(K_{xx})^{-1}K_{xx*}\\right)
|
||||||
\nu := \texttt{Degrees of freedom}
|
\\nu := \\texttt{Degrees of freedom}
|
||||||
"""
|
"""
|
||||||
mu, var = self.posterior._raw_predict(kern=self.kern if kern is None else kern, Xnew=Xnew,
|
mu, var = self.posterior._raw_predict(kern=self.kern if kern is None else kern, Xnew=Xnew,
|
||||||
pred_var=self._predictive_variable, full_cov=full_cov)
|
pred_var=self._predictive_variable, full_cov=full_cov)
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ class WarpedGP(GP):
|
||||||
the jacobian of the warping function here.
|
the jacobian of the warping function here.
|
||||||
|
|
||||||
.. math:
|
.. math:
|
||||||
p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\mu_{*}\\sigma^{2}_{*})
|
p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\\mu_{*}\\sigma^{2}_{*})
|
||||||
|
|
||||||
:param x_test: test locations (x_{*})
|
:param x_test: test locations (x_{*})
|
||||||
:type x_test: (Nx1) array
|
:type x_test: (Nx1) array
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ def generate_brownian_data(
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Generate brownian data - data from Brownian motion.
|
Generate brownian data - data from Brownian motion.
|
||||||
First point is always 0, and \Beta(0) = 0 - standard conditions for Brownian motion.
|
First point is always 0, and \\Beta(0) = 0 - standard conditions for Brownian motion.
|
||||||
|
|
||||||
Input:
|
Input:
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
|
||||||
|
|
@ -269,8 +269,8 @@ class TestMisc:
|
||||||
from GPy.core.parameterization.variational import NormalPosterior
|
from GPy.core.parameterization.variational import NormalPosterior
|
||||||
|
|
||||||
X_pred = NormalPosterior(X_pred_mu, X_pred_var)
|
X_pred = NormalPosterior(X_pred_mu, X_pred_var)
|
||||||
# mu = \int f(x)q(x|mu,S) dx = \int 2x.q(x|mu,S) dx = 2.mu
|
# mu = \\int f(x)q(x|mu,S) dx = \\int 2x.q(x|mu,S) dx = 2.mu
|
||||||
# S = \int (f(x) - m)^2q(x|mu,S) dx = \int f(x)^2 q(x) dx - mu**2 = 4(mu^2 + S) - (2.mu)^2 = 4S
|
# S = \\int (f(x) - m)^2q(x|mu,S) dx = \\int f(x)^2 q(x) dx - mu**2 = 4(mu^2 + S) - (2.mu)^2 = 4S
|
||||||
Y_mu_true = 2 * X_pred_mu
|
Y_mu_true = 2 * X_pred_mu
|
||||||
Y_var_true = 4 * X_pred_var
|
Y_var_true = 4 * X_pred_var
|
||||||
Y_mu_pred, Y_var_pred = m.predict_noiseless(X_pred)
|
Y_mu_pred, Y_var_pred = m.predict_noiseless(X_pred)
|
||||||
|
|
@ -684,7 +684,7 @@ class TestMisc:
|
||||||
warp_m = GPy.models.WarpedGP(
|
warp_m = GPy.models.WarpedGP(
|
||||||
X, Y
|
X, Y
|
||||||
) # , kernel=warp_k)#, warping_function=warp_f)
|
) # , kernel=warp_k)#, warping_function=warp_f)
|
||||||
warp_m[".*\.d"].constrain_fixed(1.0)
|
warp_m[r".*\.d"].constrain_fixed(1.0)
|
||||||
warp_m.optimize_restarts(
|
warp_m.optimize_restarts(
|
||||||
parallel=False, robust=False, num_restarts=5, max_iters=max_iters
|
parallel=False, robust=False, num_restarts=5, max_iters=max_iters
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class TestRVTransformation:
|
||||||
# ax.hist(phi_s, normed=True, bins=100, alpha=0.25, label='Histogram')
|
# ax.hist(phi_s, normed=True, bins=100, alpha=0.25, label='Histogram')
|
||||||
# ax.plot(phi, kde(phi), '--', linewidth=2, label='Kernel Density Estimation')
|
# ax.plot(phi, kde(phi), '--', linewidth=2, label='Kernel Density Estimation')
|
||||||
# ax.plot(phi, pdf_phi, ':', linewidth=2, label='Transformed PDF')
|
# ax.plot(phi, pdf_phi, ':', linewidth=2, label='Transformed PDF')
|
||||||
# ax.set_xlabel(r'transformed $\theta$', fontsize=16)
|
# ax.set_xlabel(r'transformed $\\theta$', fontsize=16)
|
||||||
# ax.set_ylabel('PDF', fontsize=16)
|
# ax.set_ylabel('PDF', fontsize=16)
|
||||||
# plt.legend(loc='best')
|
# plt.legend(loc='best')
|
||||||
# plt.show(block=True)
|
# plt.show(block=True)
|
||||||
|
|
|
||||||
|
|
@ -537,7 +537,7 @@ http://nbviewer.ipython.org/github/sahuguet/notebooks/blob/master/GoogleTrends%2
|
||||||
# In the notebook they did some data cleaning: remove Javascript header+footer, and translate new Date(....,..,..) into YYYY-MM-DD.
|
# In the notebook they did some data cleaning: remove Javascript header+footer, and translate new Date(....,..,..) into YYYY-MM-DD.
|
||||||
header = """// Data table response\ngoogle.visualization.Query.setResponse("""
|
header = """// Data table response\ngoogle.visualization.Query.setResponse("""
|
||||||
data = data[len(header):-2]
|
data = data[len(header):-2]
|
||||||
data = re.sub('new Date\((\d+),(\d+),(\d+)\)', (lambda m: '"%s-%02d-%02d"' % (m.group(1).strip(), 1+int(m.group(2)), int(m.group(3)))), data)
|
data = re.sub(r'new Date\((\d+),(\d+),(\d+)\)', (lambda m: '"%s-%02d-%02d"' % (m.group(1).strip(), 1+int(m.group(2)), int(m.group(3)))), data)
|
||||||
timeseries = json.loads(data)
|
timeseries = json.loads(data)
|
||||||
columns = [k['label'] for k in timeseries['table']['cols']]
|
columns = [k['label'] for k in timeseries['table']['cols']]
|
||||||
rows = map(lambda x: [k['v'] for k in x['c']], timeseries['table']['rows'])
|
rows = map(lambda x: [k['v'] for k in x['c']], timeseries['table']['rows'])
|
||||||
|
|
@ -782,7 +782,7 @@ def hapmap3(data_set='hapmap3'):
|
||||||
|
|
||||||
/ 1, iff SNPij==(B1,B1)
|
/ 1, iff SNPij==(B1,B1)
|
||||||
Aij = | 0, iff SNPij==(B1,B2)
|
Aij = | 0, iff SNPij==(B1,B2)
|
||||||
\ -1, iff SNPij==(B2,B2)
|
\\ -1, iff SNPij==(B2,B2)
|
||||||
|
|
||||||
The SNP data and the meta information (such as iid, sex and phenotype) are
|
The SNP data and the meta information (such as iid, sex and phenotype) are
|
||||||
stored in the dataframe datadf, index is the Individual ID,
|
stored in the dataframe datadf, index is the Individual ID,
|
||||||
|
|
@ -1011,7 +1011,7 @@ def singlecell_rna_seq_deng(dataset='singlecell_deng'):
|
||||||
sample_info.columns = c
|
sample_info.columns = c
|
||||||
|
|
||||||
# get the labels right:
|
# get the labels right:
|
||||||
rep = re.compile('\(.*\)')
|
rep = re.compile(r'\(.*\)')
|
||||||
def filter_dev_stage(row):
|
def filter_dev_stage(row):
|
||||||
if isnull(row):
|
if isnull(row):
|
||||||
row = "2-cell stage embryo"
|
row = "2-cell stage embryo"
|
||||||
|
|
@ -1050,7 +1050,7 @@ def singlecell_rna_seq_deng(dataset='singlecell_deng'):
|
||||||
#gene_info[file_info.name[:-18]] = inner.Refseq_IDs
|
#gene_info[file_info.name[:-18]] = inner.Refseq_IDs
|
||||||
|
|
||||||
# Strip GSM number off data index
|
# Strip GSM number off data index
|
||||||
rep = re.compile('GSM\d+_')
|
rep = re.compile(r'GSM\d+_')
|
||||||
|
|
||||||
from pandas import MultiIndex
|
from pandas import MultiIndex
|
||||||
columns = MultiIndex.from_tuples([row.split('_', 1) for row in data.columns])
|
columns = MultiIndex.from_tuples([row.split('_', 1) for row in data.columns])
|
||||||
|
|
|
||||||
|
|
@ -180,24 +180,24 @@ class NetpbmFile(object):
|
||||||
"""Read PAM header and initialize instance."""
|
"""Read PAM header and initialize instance."""
|
||||||
regroups = re.search(
|
regroups = re.search(
|
||||||
b"(^P7[\n\r]+(?:(?:[\n\r]+)|(?:#.*)|"
|
b"(^P7[\n\r]+(?:(?:[\n\r]+)|(?:#.*)|"
|
||||||
b"(HEIGHT\s+\d+)|(WIDTH\s+\d+)|(DEPTH\s+\d+)|(MAXVAL\s+\d+)|"
|
rb"(HEIGHT\s+\d+)|(WIDTH\s+\d+)|(DEPTH\s+\d+)|(MAXVAL\s+\d+)|"
|
||||||
b"(?:TUPLTYPE\s+\w+))*ENDHDR\n)", data).groups()
|
rb"(?:TUPLTYPE\s+\w+))*ENDHDR\n)", data).groups()
|
||||||
self.header = regroups[0]
|
self.header = regroups[0]
|
||||||
self.magicnum = b'P7'
|
self.magicnum = b'P7'
|
||||||
for group in regroups[1:]:
|
for group in regroups[1:]:
|
||||||
key, value = group.split()
|
key, value = group.split()
|
||||||
setattr(self, unicode(key).lower(), int(value))
|
setattr(self, unicode(key).lower(), int(value))
|
||||||
matches = re.findall(b"(TUPLTYPE\s+\w+)", self.header)
|
matches = re.findall(rb"(TUPLTYPE\s+\w+)", self.header)
|
||||||
self.tupltypes = [s.split(None, 1)[1] for s in matches]
|
self.tupltypes = [s.split(None, 1)[1] for s in matches]
|
||||||
|
|
||||||
def _read_pnm_header(self, data):
|
def _read_pnm_header(self, data):
|
||||||
"""Read PNM header and initialize instance."""
|
"""Read PNM header and initialize instance."""
|
||||||
bpm = data[1:2] in b"14"
|
bpm = data[1:2] in b"14"
|
||||||
regroups = re.search(b"".join((
|
regroups = re.search(b"".join((
|
||||||
b"(^(P[123456]|P7 332)\s+(?:#.*[\r\n])*",
|
rb"(^(P[123456]|P7 332)\s+(?:#.*[\r\n])*",
|
||||||
b"\s*(\d+)\s+(?:#.*[\r\n])*",
|
rb"\s*(\d+)\s+(?:#.*[\r\n])*",
|
||||||
b"\s*(\d+)\s+(?:#.*[\r\n])*" * (not bpm),
|
rb"\s*(\d+)\s+(?:#.*[\r\n])*" * (not bpm),
|
||||||
b"\s*(\d+)\s(?:\s*#.*[\r\n]\s)*)")), data).groups() + (1, ) * bpm
|
rb"\s*(\d+)\s(?:\s*#.*[\r\n]\s)*)")), data).groups() + (1, ) * bpm
|
||||||
self.header = regroups[0]
|
self.header = regroups[0]
|
||||||
self.magicnum = regroups[1]
|
self.magicnum = regroups[1]
|
||||||
self.width = int(regroups[2])
|
self.width = int(regroups[2])
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ with open('../../GPy/__version__.py', 'r') as f:
|
||||||
version = f.read()
|
version = f.read()
|
||||||
release = version
|
release = version
|
||||||
|
|
||||||
print version
|
print(version)
|
||||||
|
|
||||||
# version = '0.8.8'
|
# version = '0.8.8'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue