Gaussian Processes Regression(GPR) 高斯过程回归 Matlab 实现

高斯过程回归(GPR)的matlab 实现, Matlab 为实现高斯过程回归提供了接口函数 fitrgp, 详细参考fitrgp官方文档 非常详细[4]

语法: 

gprMdl = fitrgp(tbl,ResponseVarName)

gprMdl = fitrgp(tbl,formula)

gprMdl = fitrgp(tbl,y)

gprMdl = fitrgp(X,y)

gprMdl = fitrgp(___,Name,Value)

 

Example 1 :

这个例子用到鲍鱼数据[1],[2], 来自于知识库[3]来预测鲍鱼的年龄. 下载数据保存到你当前的文件夹命名 'abalone.data'.

tbl = readtable('abalone.data','Filetype','text',...
     'ReadVariableNames',false);
tbl.Properties.VariableNames = {'Sex','Length','Diameter','Height',...
     'WWeight','SWeight','VWeight','ShWeight','NoShellRings'};
tbl(1:7,:)

gprMdl = fitrgp(tbl,'NoShellRings','KernelFunction','ardsquaredexponential',...
      'FitMethod','sr','PredictMethod','fic','Standardize',1)
  
ypred = resubPredict(gprMdl);

figure();
plot(tbl.NoShellRings,'r.');
hold on
plot(ypred,'b');
xlabel('x');
ylabel('y');
legend({'data','predictions'},'Location','Best');
axis([0 4300 0 30]);
hold off;

L = resubLoss(gprMdl)


                                

Example 2 :

简单的生成数据训练GRP模型并画出预测值

rng(0,'twister'); % For reproducibility
n = 1000;
x = linspace(-10,10,n)';
y = 1 + x*5e-2 + sin(x)./x + 0.2*randn(n,1);

gprMdl = fitrgp(x,y,'Basis','linear',...
      'FitMethod','exact','PredictMethod','exact');
ypred = resubPredict(gprMdl);
plot(x,y,'b.');
hold on;x
plot(x,ypred,'r','LineWidth',1.5);
xlabel('x');
ylabel('y');
legend('Data','GPR predictions');
hold off

                                

注意:

ypred = resubPredict(gprMdl), 注意这里的预测语句,resubPredict(gprMdl) 这个函数输入是训练好的gprMdl模型。然后对应于训练数据x预测相应的y,是用训练好的模型,重新预测训练数据x对应的y值.

 

Example 3 :

简单数据训练高斯过程回归模型并画出带有间隔(置信区间的)图形 

x = [-4;-2;-1;0;2];
y = [-2;0;1;2;-1];
gpr = fitrgp(x,y,'Sigma',0.1);
plot(x,y,'b+','DisplayName','Data');
hold on;
xtest = linspace(-5,5,1000)';
[pred,~,ci] = predict(gpr,xtest);
plot(xtest,pred,'r','DisplayName','Prediction');
hold on;
plot(xtest,ci(:,1),'c','DisplayName','Lower 95% Limit');
plot(xtest,ci(:,2),'k','DisplayName','Upper 95% Limit');
legend('show','Location','Best');
shg;

                                  

 

 

参考:

[1] Warwick J. N., T. L. Sellers, S. R. Talbot, A. J. Cawthorn, and W. B. Ford. "The Population Biology of Abalone (_Haliotis_ species) in Tasmania. I. Blacklip Abalone (_H. rubra_) from the North Coast and Islands of Bass Strait." Sea Fisheries Division, Technical Report No. 48 (ISSN 1034-3288), 1994.

[2] S. Waugh. "Extending and Benchmarking Cascade-Correlation", PhD Thesis. Computer Science Department, University of Tasmania, 1995.

[3] Lichman, M. UCI Machine Learning Repository, Irvine, CA: University of California, School of Information and Computer Science, 2013. http://archive.ics.uci.edu/ml.

[4] fitrgp 官方文档(非常详细)

  • 29
    点赞
  • 185
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Baobin Zhang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值