forked from lawrennd/gp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemSpgp1d2.m
43 lines (32 loc) · 898 Bytes
/
demSpgp1d2.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
36
37
38
39
40
41
42
43
% DEMSPGP1D2 Do a simple 1-D regression after Snelson & Ghahramani's example.
% GP
% Fix seeds
randn('seed', 2e5);
rand('seed', 2e5);
seedVal = 2e5;
dataSetName = 'spgp1d';
experimentNo = 2;
% load data
[X, y] = mapLoadData(dataSetName, seedVal);
% Set up model
options = gpOptions('fitc');
options.numActive = 9;
% use the deterministic training conditional.
q = size(X, 2);
d = size(y, 2);
model = gpCreate(q, d, X, y, options);
model.X_u = randn(9, 1)*0.25 - 0.75;
params = gpExtractParam(model);
model = gpExpandParam(model, params);
% Optimise the model.
iters = 1000;
display = 1;
model.beta = 4/var(y);
model.kern.variance = var(y);
model.kern.inverseWidth = 1./((-min(X)+max(X))'/2).^2
model = gpOptimise(model, display, iters);
% Save the results.
capName = dataSetName;;
capName(1) = upper(capName(1));
save(['dem' capName num2str(experimentNo) '.mat'], 'model');
demSpgp1dPlot