高斯过程理解-好文

166 篇文章 17 订阅

 

 

 

def plot_unit_gaussian_samples(D):
    p = figure(plot_width=800, plot_height=500,
               title='Samples from a unit {}D Gaussian'.format(D))

    xs = np.linspace(0, 1, D)
    for color in Category10[10]:
        ys = np.random.multivariate_normal(np.zeros(D), np.eye(D))
        p.line(xs, ys, line_width=1, color=color)
    return p

show(plot_unit_gaussian_samples(2))

 

 

show(plot_unit_gaussian_samples(20))

 

 

def k(xs, ys, sigma=1, l=1):
    """Sqared Exponential kernel as above but designed to return the whole
    covariance matrix - i.e. the pairwise covariance of the vectors xs & ys.
    Also with two parameters which are discussed at the end."""

    # Pairwise difference matrix.
    dx = np.expand_dims(xs, 1) - np.expand_dims(ys, 0)
    return (sigma ** 2) * np.exp(-((dx / l) ** 2) / 2)

def m(x):
    """The mean function. As discussed, we can let the mean always be zero."""
    return np.zeros_like(x)

 We can plot this kernel to show how it’s maximised when x=x′x=x′ and then smoothly falls off as the two inputs start to differ.

N = 100
x = np.linspace(-2, 2, N)
y = np.linspace(-2, 2, N)
d = k(x, y)

color_mapper = LinearColorMapper(palette="Plasma256", low=0, high=1)

p = figure(plot_width=400, plot_height=400, x_range=(-2, 2), y_range=(-2, 2),
           title='Visualisation of k(x, x\')', x_axis_label='x',
           y_axis_label='x\'', toolbar_location=None)
p.image(image=[d], color_mapper=color_mapper, x=-2, y=-2, dw=4, dh=4)

color_bar = ColorBar(color_mapper=color_mapper, ticker=BasicTicker(),
                     label_standoff=12, border_line_color=None, location=(0,0))

p.add_layout(color_bar, 'right')

show(p)

 

 

p = figure(plot_width=800, plot_height=500)
D = 20
xs = np.linspace(0, 1, D)
for color in Category10[10]:
    ys = np.random.multivariate_normal(m(xs), k(xs, xs))
    p.circle(xs, ys, size=3, color=color)
    p.line(xs, ys, line_width=1, color=color)

show(p)

 

 

n = 100
xs = np.linspace(-5, 5, n)
K = k(xs, xs)
mu = m(xs)

p = figure(plot_width=800, plot_height=500)

for color in Category10[5]:
    ys = np.random.multivariate_normal(mu, K)
    p.line(xs, ys, line_width=2, color=color)
show(p)

 

 

# coefs[i] is the coefficient of x^i
coefs = [6, -2.5, -2.4, -0.1, 0.2, 0.03]

def f(x):
    total = 0
    for exp, coef in enumerate(coefs):
        total += coef * (x ** exp)
    return total

xs = np.linspace(-5.0, 3.5, 100)
ys = f(xs)

p = figure(plot_width=800, plot_height=400, x_axis_label='x',
           y_axis_label='f(x)', title='The hidden function f(x)')
p.line(xs, ys, line_width=2)
show(p)

 

 

 

 

p = figure(plot_width=800, plot_height=600, y_range=(-7, 8))

y_true = f(x_s)
p.line(x_s, y_true, line_width=3, color='black', alpha=0.4,
       line_dash='dashed', legend='True f(x)')

p.cross(x_obs, y_obs, size=20, legend='Training data')

stds = np.sqrt(Sigma_s.diagonal())
err_xs = np.concatenate((x_s, np.flip(x_s, 0)))
err_ys = np.concatenate((mu_s + 2 * stds, np.flip(mu_s - 2 * stds, 0)))
p.patch(err_xs, err_ys, alpha=0.2, line_width=0, color='grey',
        legend='Uncertainty')

for color in Category10[3]:
    y_s = np.random.multivariate_normal(mu_s, Sigma_s)
    p.line(x_s, y_s, line_width=1, color=color)

p.line(x_s, mu_s, line_width=3, color='blue', alpha=0.4, legend='Mean')
show(p)

 

 

Resources


 

http://bridg.land/posts/gaussian-processes-1

高斯过程回归(Gaussian Process Regression, GPR)是贝叶斯机器学习的一种重要方法,它是一种非常灵活的回归方法,可以在不确定输入和输出的情况下进行预测。本文将对高斯过程回归的相关文献进行综述,从理论和应用两个方面介绍和探讨。 一、理论研究 1.高斯过程回归的基本概念 高斯过程回归是一种基于高斯过程的非参数回归方法。高斯过程是定义在无穷维空间上的随机过程,可以理解为一个连续的随机函数。高斯过程回归的基本思想是,将输入变量x和输出变量y都视为随机变量,并认为它们之间的关系可以用高斯过程来建模。 具体来说,给定一组输入变量$x=(x_1,x_2,...,x_n)$和相应的输出变量$y=(y_1,y_2,...,y_n)$,高斯过程回归的目标是预测新的输入变量$x_*$对应的输出变量$y_*$的值。高斯过程回归方法首先通过训练数据学习一个高斯过程模型,然后利用该模型对新的输入变量进行预测。 2.高斯过程回归的核函数 高斯过程回归的核函数是一种衡量输入变量之间相似性的函数,可以用来构建高斯过程模型。常见的核函数包括线性核、多项式核、径向基核等。其中,径向基核是高斯过程回归中使用最广泛的核函数之一,它可以表示为: $k(x,x_*)=\sigma_f^2exp(-\frac{||x-x_*||^2}{2l^2})+\sigma_n^2\delta_{x,x_*}$ 其中,$\sigma_f^2$和$l$分别表示高斯过程的方差和长度尺度,$\sigma_n^2$表示噪声的方差,$\delta_{x,x_*}$是Kronecker delta函数。 3.高斯过程回归的贝叶斯推断 高斯过程回归的贝叶斯推断是一种基于贝叶斯定理的方法,可以用来估计高斯过程回归模型的参数。贝叶斯推断的基本思想是,将模型的参数视为随机变量,并通过先验分布和后验分布的计算来确定参数的后验分布。 具体来说,高斯过程回归的贝叶斯推断方法包括以下步骤:首先,选择一个先验分布来描述高斯过程回归模型的参数;然后,根据训练数据计算参数的后验分布;最后,利用参数的后验分布来对新的输入变量进行预测。 二、应用研究 1.高斯过程回归在时间序列预测中的应用 高斯过程回归在时间序列预测中的应用非常广泛。例如,凯文·墨菲(Kevin Murphy)等人提出了一种基于高斯过程回归的时间序列预测方法,该方法可以用来预测非线性时间序列数据的趋势和周期性变化。 2.高斯过程回归在机器人路径规划中的应用 高斯过程回归在机器人路径规划中也有广泛的应用。例如,王俊等人提出了一种基于高斯过程回归的机器人路径规划方法,该方法可以根据机器人的运动学和动力学特性来进行路径规划,同时考虑环境的不确定性和噪声。 3.高斯过程回归在医学图像处理中的应用 高斯过程回归在医学图像处理中的应用也非常广泛。例如,文国平等人提出了一种基于高斯过程回归的医学图像恢复方法,该方法可以对医学图像中的噪声和失真进行有效的去除和恢复。 综上所述,高斯过程回归作为一种非常灵活的回归方法,已经在各个领域得到了广泛的应用。未来,随着人工智能技术的不断发展,高斯过程回归将继续发挥其重要作用,为各种应用场景提供更加精确和高效的预测和决策支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值