main content

gaussian process regression model -凯发k8网页登录

gaussian process regression model

description

regressiongp is a gaussian process regression (gpr) model. you can train a gpr model, using fitrgp. using the trained model, you can

  • predict responses for training data using resubpredict or new predictor data using predict. you can also compute the prediction intervals.

  • compute the regression loss for training data using resubloss or new data using loss.

creation

create a regressiongp object by using fitrgp.

properties

fitting

method used to estimate the basis function coefficients, β; noise standard deviation, σ; and kernel parameters, θ, of the gpr model, stored as a character vector. it can be one of the following.

fit methoddescription
'none'no estimation. fitrgp uses the initial parameter values as the parameter values.
'exact'exact gaussian process regression.
'sd'subset of data points approximation.
'sr'subset of regressors approximation.
'fic'fully independent conditional approximation.

explicit basis function used in the gpr model, stored as a character vector or a function handle. it can be one of the following. if n is the number of observations, the basis function adds the term h*β to the model, where h is the basis matrix and β is a p-by-1 vector of basis coefficients.

explicit basisbasis matrix
'none'empty matrix.
'constant'

h=1

(n-by-1 vector of 1s, where n is the number of observations)

'linear'

h=[1,x]

'purequadratic'

h=[1,x,x2],

where

x2=[x112x122x1d2x212x222x2d2xn12xn22xnd2].

function handle

function handle, hfcn, that fitrgp calls as:

h=hfcn(x),

where x is an n-by-d matrix of predictors and h is an n-by-p matrix of basis functions.

data types: char | function_handle

estimated coefficients for the explicit basis functions, stored as a vector. you can define the explicit basis function by using the basisfunction name-value pair argument in fitrgp.

data types: double

estimated noise standard deviation of the gpr model, stored as a scalar value.

data types: double

categorical predictor indices, specified as a vector of positive integers. categoricalpredictors contains index values indicating that the corresponding predictors are categorical. the index values are between 1 and p, where p is the number of predictors used to train the model. if none of the predictors are categorical, then this property is empty ([]).

data types: single | double

this property is read-only.

cross-validation optimization of hyperparameters, specified as a bayesianoptimization object or a table of hyperparameters and associated values. this property is nonempty if the 'optimizehyperparameters' name-value pair argument is nonempty when you create the model. the value of hyperparameteroptimizationresults depends on the setting of the optimizer field in the hyperparameteroptimizationoptions structure when you create the model.

value of optimizer fieldvalue of hyperparameteroptimizationresults
'bayesopt' (default)object of class bayesianoptimization
'gridsearch' or 'randomsearch'table of hyperparameters used, observed objective function values (cross-validation loss), and rank of observations from lowest (best) to highest (worst)

maximized marginal log likelihood of the gpr model, stored as a scalar value if the fitmethod is different from 'none'. if fitmethod is 'none', then loglikelihood is empty.

if fitmethod is 'sd', 'sr', or 'fic', then loglikelihood is the maximized approximation of the marginal log likelihood of the gpr model.

data types: double

parameters used for training the gpr model, stored as a gpparams object.

kernel function

form of the covariance function used in the gpr model, stored as a character vector containing the name of the built-in covariance function or a function handle. it can be one of the following.

functiondescription
'squaredexponential'squared exponential kernel.
'matern32'matern kernel with parameter 3/2.
'matern52'matern kernel with parameter 5/2.
'ardsquaredexponential'squared exponential kernel with a separate length scale per predictor.
'ardmatern32'matern kernel with parameter 3/2 and a separate length scale per predictor.
'ardmatern52'matern kernel with parameter 5/2 and a separate length scale per predictor.
function handlea function handle that fitrgp can call like this:
kmn = kfcn(xm,xn,theta)
where xm is an m-by-d matrix, xn is an n-by-d matrix and kmn is an m-by-n matrix of kernel products such that kmn(i,j) is the kernel product between xm(i,:) and xn(j,:).
theta is the r-by-1 unconstrained parameter vector for kfcn.

data types: char | function_handle

information about the parameters of the kernel function used in the gpr model, stored as a structure with the following fields.

field namedescription
namename of the kernel function
kernelparametersvector of the estimated kernel parameters
kernelparameternamesnames associated with the elements of kernelparameters.

data types: struct

prediction

method that predict uses to make predictions from the gpr model, stored as a character vector. it can be one of the following.

predictmethoddescription
'exact'exact gaussian process regression
'bcd'block coordinate descent
'sd'subset of data points approximation
'sr'subset of regressors approximation
'fic'fully independent conditional approximation

weights used to make predictions from the trained gpr model, stored as a numeric vector. predict computes the predictions for a new predictor matrix by using the product

k(xnew,a)*α.

k(xnew,a) is the matrix of kernel products between xnew and active set vector a and α is a vector of weights.

data types: double

information on block coordinate descent (bcd)-based computation of alpha when predictmethod is 'bcd', stored as a structure containing the following fields.

field namedescription
gradientn-by-1 vector containing the gradient of the bcd objective function at convergence.
objectivescalar containing the bcd objective function at convergence.
selectioncountsn-by-1 integer vector indicating the number of times each point was selected into a block during bcd.

alpha property contains the alpha vector computed from bcd.

if predictmethod is not 'bcd', then bcdinformation is empty.

data types: struct

transformation applied to the predicted response, stored as a character vector describing how the response values predicted by the model are transformed. in regressiongp, responsetransform is 'none' by default, and regressiongp does not use responsetransform when making predictions.

active set selection

subset of training data used to make predictions from the gpr model, stored as a matrix.

predict computes the predictions for a new predictor matrix by using the product

k(xnew,a)*α.

k(xnew,a) is the matrix of kernel products between xnew and active set vector a and α is a vector of weights.

activesetvectors is equal to the training data x for exact gpr fitting and a subset of the training data x for sparse gpr methods. when there are categorical predictors in the model, activesetvectors contains dummy variables for the corresponding predictors.

data types: double

history of interleaved active set selection and parameter estimation for fitmethod equal to 'sd', 'sr', or 'fic', stored as a structure with the following fields.

field namedescription
parametervectorcell array containing the parameter vectors: basis function coefficients, β, kernel function parameters θ, and noise standard deviation σ.
activesetindicescell array containing the active set indices.
loglikelihoodvector containing the maximized log likelihoods.
criterionprofilecell array containing the active set selection criterion values as the active set grows from size 0 to its final size.

data types: struct

method used to select the active set for sparse methods ('sd','sr', or 'fic'), stored as a character vector. it can be one of the following.

activesetmethoddescription
'sgma'sparse greedy matrix approximation
'entropy'differential entropy-based selection
'likelihood'subset of regressors log likelihood-based selection
'random'random selection

the selected active set is used in parameter estimation or prediction, depending on the choice of fitmethod and predictmethod in fitrgp.

size of the active set for sparse methods ('sd','sr', or 'fic'), stored as an integer value.

data types: double

indicators for selected active set for making predictions from the trained gpr model, stored as a logical vector. these indicators mark the subset of training data that fitrgp selects as the active set. for example, if x is the original training data, then activesetvectors = x(isactivesetvector,:).

data types: logical

training data

number of observations in training data, stored as a scalar value.

data types: double

training data, stored as an n-by-d table or matrix, where n is the number of observations and d is the number of predictor variables (columns) in the training data. if the gpr model is trained on a table, then x is a table. otherwise, x is a matrix.

data types: double | table

observed response values used to train the gpr model, stored as an n-by-1 vector, where n is the number of observations.

data types: double

names of predictors used in the gpr model, stored as a cell array of character vectors. each name (cell) corresponds to a column in x.

data types: cell

names of expanded predictors for the gpr model, stored as a cell array of character vectors. each name (cell) corresponds to a column in activesetvectors.

if the model uses dummy variables for categorical variables, then expandedpredictornames includes the names that describe the expanded variables. otherwise, expandedpredictornames is the same as predictornames.

data types: cell

name of the response variable in the gpr model, stored as a character vector.

data types: char

means of predictors used for training the gpr model if the training data is standardized, stored as a 1-by-d vector. if the training data is not standardized, predictorlocation is empty.

if predictorlocation is not empty, then the method centers the predictor values by subtracting the respective element of predictorlocation from every column of x.

if there are categorical predictors, then predictorlocation includes a 0 for each dummy variable corresponding to those predictors. the dummy variables are not centered or scaled.

data types: double

standard deviations of predictors used for training the gpr model if the training data is standardized, stored as a 1-by-d vector. if the training data is not standardized, predictorscale is empty.

if predictorscale is not empty, the method scales the predictors by dividing every column of x by the respective element of predictorscale (after centering using predictorlocation).

if there are categorical predictors, then predictorlocation includes a 1 for each dummy variable corresponding to those predictors. the dummy variables are not centered or scaled.

data types: double

indicators for rows used in training the gpr model, stored as a logical vector. if all rows are used in training the model, then rowsused is empty.

data types: logical

object functions

reduce size of machine learning model
cross-validate machine learning model
limelocal interpretable model-agnostic explanations (lime)
regression error for gaussian process regression model
partialdependencecompute partial dependence
plotpartialdependencecreate partial dependence plot (pdp) and individual conditional expectation (ice) plots
compute post-fit statistics for the exact gaussian process regression model
predict response of gaussian process regression model
resubstitution regression loss
predict responses for training data using trained regression model
shapleyshapley values

examples

generate sample data.

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);

fit a gpr model using a linear basis function and the exact fitting method to estimate the parameters. also use the exact prediction method.

gprmdl = fitrgp(x,y,'basis','linear',...
      'fitmethod','exact','predictmethod','exact');

predict the response corresponding to the rows of x (resubstitution predictions) using the trained model.

ypred = resubpredict(gprmdl);

plot the true response with the predicted values.

plot(x,y,'b.');
hold on;
plot(x,ypred,'r','linewidth',1.5);
xlabel('x');
ylabel('y');
legend('data','gpr predictions');
hold off

figure contains an axes object. the axes object with xlabel x, ylabel y contains 2 objects of type line. one or more of the lines displays its values using only markers these objects represent data, gpr predictions.

more about

tips

  • you can access the properties of this class using dot notation. for example, kernelinformation is a structure holding the kernel parameters and their names. hence, to access the kernel function parameters of the trained model gprmdl, use gprmdl.kernelinformation.kernelparameters.

extended capabilities

version history

introduced in r2015b

see also

| |

网站地图