-
Notifications
You must be signed in to change notification settings - Fork 3
/
LOOCV.m
36 lines (27 loc) · 907 Bytes
/
LOOCV.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [ E_LOO ] = LOOCV( sample, f_min )
% valid-one-out cross validation
N = size(sample.x, 1);
E_LOO.x = sample.x;
E_LOO.y = zeros(N, 1);
for i=1:N
valid.x = sample.x(i, :);
valid.y = sample.y(i);
train =sample;
train.x(i, :) = [];
train.y(i) = [];
% kriging
% srgtOPTKRG = srgtsKRGSetOptions(train.x, train.y);
% srgtSRGTKRG = srgtsKRGFit(srgtOPTKRG);
%
% yhat = srgtsKRGEvaluate(valid.x, srgtSRGTKRG);
srgtOPTPRS = srgtsPRSSetOptions(train.x, train.y);
srgtSRGTPRS = srgtsPRSFit(srgtOPTPRS);
yhat = srgtsPRSEvaluate(valid.x, srgtSRGTPRS);
% opts.type = 'BlindKriging';
% opts.regressionMaxOrder = 0;
% srgtSRGTKRG = oodacefit( train.x, train.y, opts );
% yhat = srgtSRGTKRG.predict(valid.x);
% E_LOO.y(i) = abs(valid.y - yhat) / (valid.y - 0.5*f_min);
E_LOO.y(i) = abs(valid.y - yhat);
end
end