主要内容

高斯过程回归Models

高斯进程回归(GPR)模型是基于非参数内核的概率模型。您可以使用培训GPR模型Fitrgp.function.

Consider the training set { ( x i , y i ) ; i = 1 , 2 , 。。。 , n } , where x i d y i 从未知的分发中得出。GPR模型解决了预测响应变量的值的问题 y n e w 给定新的输入矢量 x n e w 和培训数据。线性回归模型是表单

y = x T β + ε. ,

where ε. N ( 0 , σ. 2 ) 。错误方差σ.2和the coefficientsβ估计数据。GPR模型通过引入潜在变量来解释响应, f ( x i ) , i = 1 , 2 , 。。。 , n ,来自高斯过程(GP)和显式基本函数,h。潜在变量的协方差函数捕获响应的平滑度和基本函数项目投影输入 x 进入A.p- 专题空间。

A GP is a set of random variables, such that any finite number of them have a joint Gaussian distribution. If { f ( x ) , x d } 是一个gp,然后给出n观察 x 1 , x 2 , 。。。 , x n ,随机变量的关节分布 f ( x 1 ) , f ( x 2 ) , 。。。 , f ( x n ) is Gaussian. A GP is defined by its mean function m ( x ) 和covariance function, k ( x , x ) 。那是,如果 { f ( x ) , x d } is a Gaussian process, then E ( f ( x ) ) = m ( x ) C o v [ f ( x ) , f ( x ) ] = E [ { f ( x ) m ( x ) } { f ( x ) m ( x ) } ] = k ( x , x )

Now consider the following model.

h ( x ) T β + f ( x ) ,

where f ( x ) ~ G P ( 0 , k ( x , x ) ) , 那是f(x) are from a zero mean GP with covariance function, k ( x , x ) h(x) are a set of basis functions that transform the original feature vectorxin Rd进入一个新的特征向量h(x) in Rpβis ap- 1个基础函数系数矢量。该模型代表了GPR模型。响应的一个例子ycan be modeled as

P ( y i | f ( x i ) , x i ) ~ N ( y i | h ( x i ) T β + f ( x i ) , σ. 2 )

因此,GPR模型是概率模型。有一个潜在的变量f(xi)为每个观察引入 x i ,这使得GPR模型非参数。在矢量形式中,该模型相当于

P ( y | f , X ) ~ N ( y | H β + f , σ. 2 I ) ,

where

X = ( x 1 T x 2 T x n T ) , y = ( y 1 y 2 y n ) , H = ( h ( x 1 T ) h ( x 2 T ) h ( x n T ) ) , f = ( f ( x 1 ) f ( x 2 ) f ( x n ) )

潜在变量的联合分布 f ( x 1 ) , f ( x 2 ) , 。。。 , f ( x n ) in the GPR model is as follows:

P ( f | X ) ~ N ( f | 0 , K ( X , X ) ) ,

接近线性回归模型,在哪里 K ( X , X ) looks as follows:

K ( X , X ) = ( k ( x 1 , x 1 ) k ( x 1 , x 2 ) k ( x 1 , x n ) k ( x 2 , x 1 ) k ( x 2 , x 2 ) k ( x 2 , x n ) k ( x n , x 1 ) k ( x n , x 2 ) k ( x n , x n ) )

The covariance function k ( x , x ) is usually parameterized by a set of kernel parameters or hyperparameters, θ. 。Often k ( x , x ) 是书面的 k ( x , x | θ. ) 明确表示依赖 θ.

Fitrgp.估计基础函数系数, β , the noise variance, σ. 2 , and the hyperparameters, θ. , of the kernel function from the data while training the GPR model. You can specify the basis function, the kernel (covariance) function, and the initial values for the parameters.

因为GPR模型是概率的,所以可以使用训练的模型来计算预测间隔(见预测resubPredict)。

You can also compute the regression error using the trained GPR model (seelossresubLoss)。

Compare Prediction Intervals of GPR Models

此示例适用于无噪声数据集和嘈杂数据集的GPR模型。该示例比较了两个合适的GPR模型的预测响应和预测间隔。

生成两个观测数据集的功能在 g ( x ) = x sin ( x )

RNG('默认')再现性的百分比x_observed = linspace(0,10,21)';y_observed1 = x_observed。* sin(x_observed);Y_OBSERVED2 = Y_OBSERVED1 + 0.5 * RANDN(大小(X_OBSERARED));

价值Y_OBSERVED1.are noise free, and the values inY_OBSERVED2.包括一些随机噪声。

Fit GPR models to the observed data sets.

gprMdl1 = fitrgp(x_observed,y_observed1); gprMdl2 = fitrgp(x_observed,y_observed2);

Compute the predicted responses and 95% prediction intervals using the fitted models.

x = linspace(0,10)'; [ypred1,~,yint1] = predict(gprMdl1,x); [ypred2,~,yint2] = predict(gprMdl2,x);

Resize a figure to display two plots in one figure.

fig = figure; fig.Position(3) = fig.Position(3)*2;

Create a 1-by-2 tiled chart layout.

Tiledlayout(1,2,'tileespacing','compact')

For each tile, draw a scatter plot of observed data points and a function plot of x sin ( x ) 。Then add a plot of GP predicted responses and a patch of prediction intervals.

nexttile hold散射(X_Observed,Y_observed1,'r')% Observed data pointsfplot(@(x)x。* sin(x),[0,10],'--r')x * sin(x)的%函数图plot(x,ypred1,'g')%GPR预测patch([x;flipud(x)],[yint1(:,1);flipud(yint1(:,2))],'k','FaceAlpha',0.1);% Prediction intervalshold离开title('GPR无噪音观察') 传奇({'Noise-free observations','g(x) = x*sin(x)','GPR预测','95% prediction intervals'},'地点','best') nexttile hold分散(X_Observed,Y_observed2,'xr')% Observed data pointsfplot(@(x)x。* sin(x),[0,10],'--r')x * sin(x)的%函数图plot(x,ypred2,'g')%GPR预测patch([x;flipud(x)],[yint2(:,1);flipud(yint2(:,2))],'k','FaceAlpha',0.1);% Prediction intervalshold离开title('GPR Fit of Noisy Observations') 传奇({'嘈杂的观察','g(x) = x*sin(x)','GPR预测','95% prediction intervals'},'地点','best')

Figure contains 2 axes objects. Axes object 1 with title GPR Fit of Noise-Free Observations contains 4 objects of type scatter, functionline, line, patch. These objects represent Noise-free observations, g(x) = x*sin(x), GPR predictions, 95% prediction intervals. Axes object 2 with title GPR Fit of Noisy Observations contains 4 objects of type scatter, functionline, line, patch. These objects represent Noisy observations, g(x) = x*sin(x), GPR predictions, 95% prediction intervals.

When the observations are noise free, the predicted responses of the GPR fit cross the observations. The standard deviation of the predicted response is almost zero. Therefore, the prediction intervals are very narrow. When observations include noise, the predicted responses do not cross the observations, and the prediction intervals become wide.

参考

[1] Rasmussen,C. E.和C.K. I.威廉姆斯。Gaussian Processes for Machine Learning.MIT Press。剑桥,马萨诸塞州,2006年。

See Also

||

相关话题