RegressionGP
statistics: RegressionGP
Create a RegressionGP object containing a Gaussian process
regression model.
obj = RegressionGP (X, Y) returns a Gaussian
process regression model, obj, with X being the predictor data
and Y the continuous response of the observations in X.
A Gaussian process places a prior over functions, given by the covariance
function, and conditions it on the observations. The response is modelled
as plus a draw from that process plus independent noise of
standard deviation Sigma, where is the explicit basis. The
covariance parameters and Sigma are estimated by maximizing the log
marginal likelihood, and Beta follows from them in closed form as
the generalized least squares estimate.
obj = RegressionGP (…, name, value) returns a
model with additional options specified by Name-Value pair
arguments listed below.
| Name | Value |
|---|---|
'KernelFunction' | A character vector naming the covariance
function, or a function handle taking two matrices of points and a parameter
vector. The default is 'squaredexponential'. The supported names
are listed below. |
'KernelParameters' | A numeric vector of initial values for the covariance parameters. Its length depends on the covariance function. These are starting values for the optimization, not fixed values. |
'BasisFunction' | A character vector naming the explicit
basis, one of 'none', 'constant', 'linear' or
'pureQuadratic', or a function handle taking X and returning
the basis matrix. The default is 'constant'. |
'Beta' | A numeric vector of basis coefficients. These are
used as known values only when 'FitMethod' is 'none'. |
'Sigma' | A positive scalar, the initial value of the noise
standard deviation. The default is std (Y) / sqrt (2). |
'ConstantSigma' | A logical scalar. When true the
noise standard deviation is held at its initial value instead of being
estimated. The default is false. |
'SigmaLowerBound' | A positive scalar bounding the noise
standard deviation from below. The default is
1e-2 * std (Y). |
'FitMethod' | A character vector, either 'exact' to
estimate the parameters or 'none' to keep them at their initial
values. The default is 'exact'. |
'PredictMethod' | A character vector. Only 'exact'
is implemented, which is also the only method under which a standard
deviation and a prediction interval are available. |
'Optimizer' | A character vector naming the optimizer used
to maximize the log marginal likelihood. 'quasinewton' and
'fminunc' name the same dense solver and are the default,
'lbfgs' selects limited-memory BFGS, which holds a fixed number of
curvature pairs rather than a full inverse Hessian and is the cheaper
choice when the kernel carries many parameters, and 'fminsearch'
is derivative-free. |
'Standardize' | A logical scalar specifying whether the
predictor data should be centred and scaled before training. The same
transformation is applied by predict. The default is false. |
'Weights' | An numeric vector of non-negative observation weights. The default is a vector of ones. |
'PredictorNames' | A cell array of character vectors naming the predictors, in the order they appear in X. |
'ResponseName' | A character vector naming the response.
The default is 'Y'. |
'ResponseTransform' | A character vector or a function
handle applied to the response the model predicts. The default is
'none'. |
Source Code: RegressionGP
The supported values for 'KernelFunction' are:
| Value | Parameters |
|---|---|
'exponential' | [SigmaL; SigmaF] |
'squaredexponential' | [SigmaL; SigmaF] |
'matern32' | [SigmaL; SigmaF] |
'matern52' | [SigmaL; SigmaF] |
'rationalquadratic' | [SigmaL; AlphaRQ; SigmaF] |
'ardexponential' | [LengthScale1; …; SigmaF] |
'ardsquaredexponential' | [LengthScale1; …; SigmaF] |
'ardmatern32' | [LengthScale1; …; SigmaF] |
'ardmatern52' | [LengthScale1; …; SigmaF] |
'ardrationalquadratic' | [LengthScale1; …; AlphaRQ; SigmaF] |
Source Code: RegressionGP
The automatic relevance determination kernels carry one length scale per predictor, so a predictor the response does not depend on is given a large length scale and stops contributing.
The supported values for 'ResponseTransform' are:
| Value | Description |
|---|---|
'none' | (no transformation) |
'identity' | (no transformation) |
'exp' | |
'log' |
Source Code: RegressionGP
Two deviations from MATLAB are deliberate and documented. The distance
between points is accumulated one predictor at a time instead of by the
expanded form MATLAB uses by default, because the expanded form does not
return exactly zero for a point against itself and the rough kernels
amplify that residue through their square root. The approximate fitting
and prediction methods, 'sd', 'sr', 'fic' and
'bcd', together with the active set options that serve them, are
not implemented and are refused rather than silently ignored.
See also: fitrgp, CompactRegressionGP, RegressionSVM, RegressionGAM
Source Code: RegressionGP
The RegressionGP class contains the following properties:
An numeric matrix, as it was supplied to the constructor. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
An numeric vector, as it was supplied to the constructor. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A positive integer scalar, counting only the rows that survived the removal of missing values. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A logical vector with one element per row of the data as supplied, true where the row was used. It is empty when no row was dropped. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
An numeric vector, one weight per observation used to train the model. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A cell array of character vectors, one per column of X. This
property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A cell array of character vectors. It differs from
PredictorNames only where a categorical predictor has been
expanded into indicator variables. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A character vector. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A vector of positive integers indexing the columns of X that
hold categorical predictors, or empty when none does. This property is
read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A cell array with one entry per predictor, holding that predictor’s bin edges where the model discretized it before fitting. It is empty here and stays empty: a Gaussian process takes its predictors as they are.
This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
'Exact' when the covariance parameters and the noise were
estimated by maximizing the log marginal likelihood, and 'None'
when they were kept at their initial values. This property is
read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
'None', 'Constant', 'Linear',
'PureQuadratic', or the function handle that was supplied. This
property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A numeric vector with one element per basis term, empty when the basis
is 'None'. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A positive scalar. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A scalar, or empty when FitMethod is 'None' and nothing
was maximized. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A structure holding the options the fit was performed under. MATLAB returns an object of its own class here; a structure carries the same information and is what every other learner in this package returns.
Beta, Sigma and KernelParameters are the
starting values the fit was given, empty or zero where it was
given none, as they are in MATLAB. What the fit found is reported by
the Beta and Sigma properties and by
KernelInformation. Beta defaults to a zero for every
column the basis contributes, so a 'linear' basis over three
predictors starts at four zeros.
SigmaLowerBound is the exception and is reported as it was
resolved. MATLAB publishes no top-level field of that name, keeping
it inside an Options structure this class does not carry.
The fields MATLAB reports for its approximate fitting methods
(ActiveSet, Options, OptimizerOptions,
ConstantKernelParameters, InitialStepSize,
InitialSigmaLowerBoundTolerance, Verbose and
CacheSize) are absent, this class implementing exact fitting
alone. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A character vector naming the covariance function, or the function handle that was supplied. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A structure with fields Name, KernelParameters and
KernelParameterNames, the last naming each parameter in the
order they are stored. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
'Exact'. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
An numeric vector. A prediction is the basis term plus the covariance between the new point and the active set, weighted by these. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
An numeric matrix, standardized where the model standardized its predictors. It is the whole of the training data, since only the exact method is implemented. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
'Random'. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A positive integer scalar. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A logical vector with one element per training observation. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
Always empty. It is declared for MATLAB compatibility, where it records the active set chosen at each iteration by a fit method that builds one. This class implements the exact method alone, which uses the whole of the training data and selects nothing, so there is no history to record. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
Always empty. It is declared for MATLAB compatibility, where it records a block coordinate descent. This class does not use that method, so there is nothing to report. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A numeric vector when the model standardized its predictors, and empty when it did not. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A numeric vector when the model standardized its predictors, and empty when it did not. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
Always empty. It is declared for MATLAB compatibility, where it holds what an automatic search over the hyperparameters found. This class fits the parameters it is given and runs no such search, so there is nothing to report. This property is read-only.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
A character vector, or the text of the function handle that was supplied. Assigning to it accepts either.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
The RegressionGP class offers the following public methods:
RegressionGP: yFit = predict (obj, XC)
RegressionGP: [yFit, ySD, yInt] = predict (obj, XC)
RegressionGP: […] = predict (…, 'Alpha', alpha)
yFit = predict (obj, XC) returns the predicted
response of the RegressionGP model obj at the points in
XC, which must have as many columns as the model has predictors.
[yFit, ySD, yInt] = predict (…) also
returns the standard deviation of each predicted response and the
prediction intervals. The standard deviation is that of a new
response, so it carries the noise as well as the uncertainty of
the latent function, and the interval is the normal quantile of the
level times it.
[…] = predict (…, sets
the significance level of the intervals, so that they are
per cent intervals. alpha must be
a scalar in the range and defaults to .
'Alpha', alpha)
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
RegressionGP: yFit = resubPredict (obj)
RegressionGP: [yFit, ySD, yInt] = resubPredict (obj)
yFit = resubPredict (obj) returns the response the
RegressionGP model obj predicts at its own training data,
and the further outputs are those of predict.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
RegressionGP: L = loss (obj, X, Y)
RegressionGP: L = loss (…, name, value)
L = loss (obj, X, Y) returns the mean
squared error of the model obj on the data X and Y.
L = loss (…, name, value) accepts
'LossFun', either 'mse', 'mae',
'epsiloninsensitive' or a function handle taking the observed
and the predicted response, and 'Weights', a vector of
non-negative observation weights.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
RegressionGP: L = resubLoss (obj)
RegressionGP: L = resubLoss (…, name, value)
L = resubLoss (obj) returns the loss of the model
obj on the data it was trained on, and accepts the same
Name-Value pairs as loss.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
RegressionGP: [loores, neff] = postFitStatistics (obj)
[loores, neff] = postFitStatistics (obj)
returns the vector of leave-one-out residuals of the model
obj, and the number of effective parameters the fit uses. Neither
requires refitting the model: both follow from the factorization the fit
already produced.
The coefficients of the explicit basis are treated as estimated, which
is what FitMethod 'Exact' makes them, while the
covariance parameters and the noise are treated as known.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
RegressionGP: CVMdl = crossval (obj)
RegressionGP: CVMdl = crossval (…, name, value)
CVMdl = crossval (obj) returns a
RegressionPartitionedModel built from the model obj by
ten-fold cross validation.
CVMdl = crossval (…, name, value) accepts
'KFold', 'Holdout', 'Leaveout' and
'CVPartition', of which at most one may be given.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
RegressionGP: CMdl = compact (obj)
CMdl = compact (obj) returns a
CompactRegressionGP object holding what is needed to predict
and nothing else: the training data, the response and everything that
describes them are dropped.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
RegressionGP: savemodel (obj, filename)
savemodel (obj, filename) saves the model obj
into filename in a form loadmodel can read back.
Fit a Gaussian process to noisy observations of a smooth function and show the prediction interval widening away from the data.
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');
x = [0.1; 0.3; 0.4; 0.7; 0.9; 1.4; 1.6; 1.9]';
x = x(:);
y = sin (3 * x) + 0.05 * cos (11 * x);
Mdl = fitrgp (x, y);
xq = linspace (-0.2, 2.2, 200)';
[yq, ~, yint] = predict (Mdl, xq);
figure ('visible', 'off');
hold on;
plot (xq, yint(:,1), 'r:');
plot (xq, yint(:,2), 'r:');
plot (xq, yq, 'b-');
plot (x, y, 'ko');
hold off;
xlabel ('x');
ylabel ('y');
title ('Gaussian process regression with 95% prediction interval');