pymc.gp.HSGP#

class pymc.gp.HSGP(m, L=None, c=None, drop_first=False, parameterization='noncentered', *, mean_func=<pymc.gp.mean.Zero object>, cov_func)[源代码]#

希尔伯特空间高斯过程近似。

gp.HSGP 类是希尔伯特空间高斯过程的一个实现。它是一种使用一组固定基向量的降秩高斯过程近似,这些基向量的系数是平稳协方差函数功率谱密度的随机函数。它的使用方式与 gp.Latent 大致相似。与 gp.Latent 一样,它不假设高斯噪声模型,可以与任何似然函数一起使用,或者作为模型中的任何组件。同样与 gp.Latent 一样,它具有 priorconditional 方法。它支持任何实现 power_spectral_density 方法的协方差函数之和。

关于选择适当的 mLc 的信息,请参考 Ruitort-Mayol 等人或使用 HSGP 的 PyMC 示例。

要使用 HSGP 的“线性化”形式,即基向量矩阵和系数向量,请参见 prior_linearized 方法。

参数:
m: 列表

每个活动维度(协方差参数 active_dim)使用的基向量数量。

L: 列表

每个 active_dim 的空间边界。它被称为边界条件。选择 L 使得域 [-L, L] 包含由 active_dim 给定的 X 列中的所有点。

c: float

比例扩展因子。用于从X构造L。定义为 S = max|X|,使得 X[-S, S] 范围内。L 计算为 c * S。必须提供 cL 之一。更多信息可以在 Ruitort-Mayol 等人中找到。

drop_first: bool

默认 False。有时第一个基向量非常“平坦”,并且与截距项非常相似。当模型中存在截距时,忽略第一个基向量可能会改善采样。

cov_func: None, 2D 数组, 或 Covariance 实例

协方差函数。默认为零。

mean_func: None, Mean 的实例

均值函数。默认为零。

参考文献

  • Ruitort-Mayol, G., 和 Anderson, M., 和 Solin, A., 和 Vehtari, A. (2022). 实用希尔伯特空间近似贝叶斯高斯过程用于概率编程

  • Solin, A., Sarkka, S. (2019) 希尔伯特空间方法用于降秩高斯过程回归。

示例

# A three dimensional column vector of inputs.
X = np.random.rand(100, 3)

with pm.Model() as model:
    # Specify the covariance function.
    # Three input dimensions, but we only want to use the last two.
    cov_func = pm.gp.cov.ExpQuad(3, ls=0.1, active_dims=[1, 2])

    # Specify the HSGP.
    # Use 25 basis vectors across each active dimension for a total of 25 * 25 = 625.
    # The value `c = 4` means the boundary of the approximation
    # lies at four times the half width of the data.
    # In this example the data lie between zero and one,
    # so the boundaries occur at -1.5 and 2.5.  The data, both for
    # training and prediction should reside well within that boundary..
    gp = pm.gp.HSGP(m=[25, 25], c=4.0, cov_func=cov_func)

    # Place a GP prior over the function f.
    f = gp.prior("f", X=X)

...

# After fitting or sampling, specify the distribution
# at new points with .conditional
Xnew = np.linspace(-1, 2, 50)[:, None]

with model:
    fcond = gp.conditional("fcond", Xnew=Xnew)

方法

HSGP.__init__(m[, L, c, drop_first, ...])

HSGP.conditional(name, Xnew[, dims])

返回在新输入位置 Xnew 上评估的(近似)条件分布。

HSGP.marginal_likelihood(name, X, *args, ...)

HSGP.predict(Xnew[, point, given, diag, model])

HSGP.prior(name, X[, dims])

返回在输入位置 X 上评估的(近似)GP 先验分布。

HSGP.prior_linearized(Xs)

HSGP 的线性化版本。

属性

L