主要内容

高斯过程回归Models

高斯工艺回归(GPR)模型是基于非参数内核的概率模型。您可以使用fitrgpfunction.

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 进入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_OBSEVER = linspace(0,10,21)';y_observed1 = x_observed。*sin(x_observed);y_observed2 = y_observed1 + 0.5*randn(size(x_observed));

值中的值y_observed1are 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,'tilespacing','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)的功能图%情节(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. Williams。Gaussian Processes for Machine Learning.麻省理工学院出版社。剑桥,马萨诸塞州,2006年。

See Also

||

相关话题